<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>js大佬de笔记 | 个人笔记</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    
    <link rel="prev" href="../../md/js/js数组对象.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="4"
        data-chapter-title="js大佬de笔记"
        data-filepath="md/js/js笔记.md"
        data-basepath="../.."
        data-revision="Fri Sep 14 2018 16:41:08 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/html/HTML5.html">
            
                
                    <a href="../../md/html/HTML5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/css/CSS笔记.html">
            
                
                    <a href="../../md/css/CSS笔记.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        css笔记
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="md/js/js基础.html">
            
                
                    <a href="../../md/js/js基础.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        JavaScript
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="md/js/js数据类型的转换.html">
            
                
                    <a href="../../md/js/js数据类型的转换.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="md/js/js运算符.html">
            
                
                    <a href="../../md/js/js运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        运算符
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="md/js/js赋值运算符.html">
            
                
                    <a href="../../md/js/js赋值运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.1.</b>
                        
                        赋值运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="md/js/js比较运算符.html">
            
                
                    <a href="../../md/js/js比较运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.2.</b>
                        
                        比较运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="md/js/js逻辑操作符.html">
            
                
                    <a href="../../md/js/js逻辑操作符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.3.</b>
                        
                        逻辑操作符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="md/js/js条件运算符.html">
            
                
                    <a href="../../md/js/js条件运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.4.</b>
                        
                        条件运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="md/js/js位运算符.html">
            
                
                    <a href="../../md/js/js位运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.5.</b>
                        
                        位运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="md/js/js条件语句.html">
            
                
                    <a href="../../md/js/js条件语句.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.6.</b>
                        
                        条件语句
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="md/js/js循环.html">
            
                
                    <a href="../../md/js/js循环.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        循环
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="md/js/jswhile循环.html">
            
                
                    <a href="../../md/js/jswhile循环.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.1.</b>
                        
                        while循环
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="md/js/jsfor循环.html">
            
                
                    <a href="../../md/js/jsfor循环.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.2.</b>
                        
                        for循环
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="md/js/js多层循环.html">
            
                
                    <a href="../../md/js/js多层循环.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.3.</b>
                        
                        多层循环
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="md/js/js函数.html">
            
                
                    <a href="../../md/js/js函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="md/js/js冒泡排序.html">
            
                
                    <a href="../../md/js/js冒泡排序.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        冒泡排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="md/js/try-catch语句.html">
            
                
                    <a href="../../md/js/try-catch语句.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        try-catch语句
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="md/js/jses6.html">
            
                
                    <a href="../../md/js/jses6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        es6
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="md/js/安装babel.html">
            
                
                    <a href="../../md/js/安装babel.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.1.</b>
                        
                        安装babel(es6转es5)
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="md/js/js数组对象.html">
            
                
                    <a href="../../md/js/js数组对象.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        数组对象
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="4" data-path="md/js/js笔记.html">
            
                
                    <a href="../../md/js/js笔记.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        js大佬de笔记
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >个人笔记</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h2 id="js-&#x7B14;&#x8BB0;">JS &#x7B14;&#x8BB0;</h2>
<h3 id="&#x7B2C;&#x4E00;&#x8282;-js&#x7684;&#x4ECB;&#x7ECD;">&#x7B2C;&#x4E00;&#x8282; js&#x7684;&#x4ECB;&#x7ECD;</h3>
<h4 id="11js&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;">1.1js&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;</h4>
<p>&#x4E09;&#x5927;&#x5757;&#xFF1A;ECMAScript,DOM,BOM.</p>
<ul>
<li>ECMAScript&#xFF1A;&#x63CF;&#x8FF0;&#x4E86;&#x8BE5;&#x8BED;JavaScript&#x7EC4;&#x6210;JavaScript&#x7EC4;&#x6210;&#x8A00;&#x7684;&#x8BED;&#x6CD5;&#x548C;&#x57FA;&#x672C;&#x5BF9;&#x8C61;&#x3002;</li>
<li>DOM(&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B;)&#xFF1A;&#x63CF;&#x8FF0;&#x5904;&#x7406;&#x7F51;&#x9875;&#x5185;&#x5BB9;&#x7684;&#x65B9;&#x6CD5;&#x548C;&#x63A5;&#x53E3;&#x3002;</li>
<li>BOM(&#x6D4F;&#x89C8;&#x5668;&#x5BF9;&#x8C61;&#x6A21;&#x578B;)&#xFF1A;&#x63CF;&#x8FF0;&#x4E0E;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#x7684;&#x65B9;&#x6CD5;&#x548C;&#x63A5;&#x53E3;&#x3002;
JavaScript&#x80FD;&#x505A;&#x4EC0;&#x4E48;&#xFF1F;<blockquote>
<p>&#x7ED9;&#x4E88;&#x9875;&#x9762;&#x7075;&#x9B42;&#xFF0C;&#x8BA9;&#x9875;&#x9762;&#x53EF;&#x4EE5;&#x52A8;&#x8D77;&#x6765;&#xFF0C;&#x5305;&#x62EC;&#x52A8;&#x6001;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x52A8;&#x6001;&#x7684;&#x6807;&#x7B7E;&#xFF0C;&#x52A8;&#x6001;&#x7684;&#x6837;&#x5F0F;&#x7B49;&#x3002;</p>
<pre><code>      &#xFF08;&#x64CD;&#x7EB5;HTML&#xFF1A;&#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684;&#x5185;&#x5BB9;&#x3001;&#x5C5E;&#x6027;&#x548C;&#x6837;&#x5F0F;&#x3002;&#xFF09;
</code></pre></blockquote>
</li>
</ul>
<p>&#x6CE8;&#x91CA;&#xFF1A;</p>
<pre><code>/*
 &#x8FD9;&#x662F;&#x4E00;&#x4E2A;
 &#x591A;&#x884C;
 &#x6CE8;&#x91CA;&#xFF0C;&#x591A;&#x884C;&#x6CE8;&#x91CA;&#x662F;&#x4E0D;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x7684;&#x3002;
* */
</code></pre><ul>
<li><p>&#x867D;&#x7136;js&#x64CD;&#x4F5C;HTML&#x7ED3;&#x6784;&#x975E;&#x5E38;&#x91CD;&#x8981;&#xFF0C;&#x4F46;js&#x7684;&#x6267;&#x884C;&#x5E76;&#x4E0D;&#x662F;&#x5B8C;&#x5168;&#x4F9D;&#x8D56;HTML&#x7ED3;&#x6784;&#x7684;js&#x5F15;&#x5165;&#x65B9;&#x5F0F;&#x3002;</p>
<ul>
<li><p>js</p>
<ul>
<li>1.&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;</li>
<li>2.&#x53E5;&#x5C3E;&#x7684;&#x5206;&#x53F7;&#x6709;&#x4E9B;&#x65F6;&#x5019;&#x662F;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x7684;&#xFF0C;&#x4F46;&#x5F3A;&#x70C8;&#x5EFA;&#x8BAE;&#x4E0D;&#x8981;&#x7701;&#x7565;&#x3002;</li>
<li>3.&#x5229;&#x7528;var&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;</li>
</ul>
</li>
<li><p>js&#x5F15;&#x5165;&#x65B9;&#x5F0F;</p>
<ul>
<li>1.&#x901A;&#x8FC7;script&#x6807;&#x7B7E;&#xFF0C;&#x5199;&#x5185;&#x90E8;js&#x4EE3;&#x7801;<ul>
<li>&#x4E00;&#x822C;&#x6211;&#x4EEC;&#x4F1A;&#x628A;script&#x6807;&#x7B7E;&#x653E;&#x5728;<code>body</code>&#x7684;&#x6700;&#x540E;&#xFF0C;&#x4F46;&#x8FD9;&#x5E76;&#x4E0D;&#x662F;&#x7EDD;&#x5BF9;&#x7684;&#xFF0C;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x653E;&#x5230;head&#x91CC;&#x9762;&#x3002;</li>
<li>&#x653E;&#x5728;&#x5E95;&#x90E8;&#x7684;&#x597D;&#x5904;&#xFF1A;<ul>
<li>a.&#x5148;&#x8BFB;&#x53D6;HTML&#x7ED3;&#x6784;&#xFF0C;&#x518D;&#x8FD0;&#x884C;js&#x4EE3;&#x7801;&#xFF0C;&#x907F;&#x514D;&#x62A5;&#x9519;&#x3002;</li>
<li>b.js&#x4EE3;&#x7801;&#x7684;&#x6267;&#x884C;&#x4F1A;&#x963B;&#x585E;HTML&#x4EE3;&#x7801;&#x7684;&#x8BFB;&#x53D6;&#xFF0C;&#x6240;&#x4EE5;&#x5982;&#x679C;&#x628A;js&#x4EE3;&#x7801;&#x653E;&#x5230;html&#x4EE3;&#x7801;&#x524D;&#x9762;&#xFF0C;&#x4F1A;&#x589E;&#x52A0;&#x7528;&#x6237;&#x770B;&#x5230;&#x9996;&#x5C4F;&#x7684;&#x65F6;&#x95F4;&#x3002;</li>
</ul>
</li>
</ul>
</li>
<li>2.&#x901A;&#x8FC7;Script&#x6807;&#x7B7E;&#x7684;<code>scr</code>&#x5C5E;&#x6027;&#x5F15;&#x5165;&#x5916;&#x90E8;&#x6587;&#x4EF6;.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 id="12-&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;&#x7684;&#x533A;&#x522B;">1.2 &#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;&#x7684;&#x533A;&#x522B;</h4>
<p>&#x53D8;&#x91CF;&#x7684;&#x503C;&#x662F;&#x53EF;&#x4EE5;&#x6539;&#x53D8;&#x7684;,&#x5E76;&#x4E14;&#x56E0;&#x4E3A;js&#x662F;&#x5F31;&#x7C7B;&#x578B;&#x8BED;&#x8A00;,&#x53D8;&#x91CF;&#x7684;&#x503C;&#x7684;&#x7C7B;&#x578B;&#x4E5F;&#x662F;&#x53EF;&#x4EE5;&#x6539;&#x53D8;&#x7684;.</p>
<ul>
<li>&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x662F;&#x901A;&#x8FC7;var&#x5173;&#x952E;&#x5B57;&#x6765;&#x5B9E;&#x73B0;&#x7684;<h4 id="13&#x53D8;&#x91CF;&#x540D;&#x7684;&#x7EA6;&#x675F;&#x6761;&#x4EF6;">1.3&#x53D8;&#x91CF;&#x540D;&#x7684;&#x7EA6;&#x675F;&#x6761;&#x4EF6;</h4>
</li>
<li>1.&#x53D8;&#x91CF;&#x540D;&#x5FC5;&#x987B;&#x4EE5;&#x5B57;&#x6BCD;&#x548C;&#x4E0B;&#x5212;&#x7EBF;/$&#x7B26;&#x53F7;&#x5F00;&#x5934;,&#x6CE8;&#x610F;&#x4E0D;&#x53EF;&#x4EE5;&#x6570;&#x5B57;&#x6216;&#x8005;&#x5176;&#x4ED6;&#x5B57;&#x7B26;&#x5F00;&#x5934;;   <pre><code>               `var 1a;//&#x9519;&#x8BEF;  `    
               `var _test;//&#x5141;&#x8BB8;`
</code></pre></li>
<li>2.&#x53D8;&#x91CF;&#x540D;&#x4E2D;&#x95F4;&#x4E0D;&#x80FD;&#x5305;&#x62EC;&#x7A7A;&#x683C;&#x548C;&#x6807;&#x70B9;&#x7B26;&#x53F7;,&#x4F46;&#x662F;&#x53EF;&#x4EE5;&#x5305;&#x62EC;&#x4E0B;&#x5212;&#x7EBF;(_)&#x548C;$&#x7B26;&#x53F7;;</li>
<li>3.&#x53D8;&#x91CF;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;,&#x4F8B;&#x5982;:var test&#x548C;Test &#x8868;&#x793A;&#x4E24;&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x53D8;&#x91CF;</li>
<li>4.&#x4E0D;&#x53EF;&#x4EE5;&#x7528;&#x4FDD;&#x7559;&#x5B57;,&#x548C;&#x5173;&#x952E;&#x5B57;&#x4F5C;&#x4E3A;&#x53D8;&#x91CF;&#x540D;;</li>
</ul>
<h5 id="&#x6CE8;&#x610F;">&#x6CE8;&#x610F;:</h5>
<ul>
<li>1.&#x53EF;&#x53EA;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x800C;&#x4E0D;&#x8D4B;&#x503C;,&#x4F8B;&#x5982;:<code>var test</code>;</li>
<li>2.&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;var&#x58F0;&#x660E;&#x591A;&#x4E2A;&#x53D8;&#x91CF;,&#x53D8;&#x91CF;&#x95F4;&#x7528;&#x9017;&#x53F7;&#x9694;&#x5F00;&#x5373;&#x53EF;,&#x6700;&#x540E;&#x7528;&#x5206;&#x53F7;&#x8868;&#x793A;&#x7ED3;&#x675F;     <pre><code>                   `&#x4F8B;&#x5982;:var test1,test2,test3;`   
</code></pre></li>
<li>3.&#x5E38;&#x7528;&#x7684;&#x53D8;&#x91CF;&#x547D;&#x540D;&#x65B9;&#x6CD5;:<ul>
<li>&#x5C0F;&#x9A7C;&#x5CF0;&#x6CD5;:&#x53D8;&#x91CF;&#x540D;&#x9664;&#x4E86;&#x7B2C;&#x4E00;&#x4E2A;&#x5355;&#x8BCD;&#x5916;,&#x5176;&#x4ED6;&#x5355;&#x8BCD;&#x9996;&#x5B57;&#x6BCD;&#x5927;&#x5199;;   <pre><code>                  `var myTest;`   
                   `var myContentTitle;`
</code></pre></li>
<li>&#x5927;&#x9A7C;&#x5CF0;&#x6CD5;:&#x6240;&#x6709;&#x5355;&#x8BCD;&#x9996;&#x5B57;&#x6BCD;&#x5927;&#x5199;;    <pre><code>                   `var MyTitle;`   
                   `var MyContentTitle;`
</code></pre></li>
<li>&#x4E0B;&#x5212;&#x7EBF;&#x5206;&#x5272;&#x6CD5;:   <pre><code>                   `var my_title;`   
                   `var my_content_title;`  
</code></pre></li>
<li>&#x5168;&#x90E8;&#x5927;&#x5199;&#x7684;&#x53D8;&#x91CF;&#x540D;,&#x4E00;&#x822C;&#x662F;&#x7528;&#x6765;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x5E38;&#x91CF;;   <pre><code>           `var CONTENT = &quot;amv&quot;;//CONTENT &#x662F;&#x4E00;&#x4E2A;&#x5E38;&#x91CF;`  
</code></pre></li>
</ul>
</li>
</ul>
<h4 id="14-&#x53D8;&#x91CF;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;">1.4 &#x53D8;&#x91CF;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;:</h4>
<ul>
<li>1.&#x6570;&#x5B57;,&#x5373;&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;0-9;&#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x6570;&#x5B66;&#x8FD0;&#x7B97;;<pre><code>  `var a = 10;`  
  `var b = 15;`   
  `var c = a+b;`   
  `console.log(c);`   
</code></pre></li>
<li>2.&#x5B57;&#x7B26;&#x4E32;,&#x5B57;&#x7B26;&#x4E32;&#x8868;&#x793A;&#x5B57;&#x7B26;&#x548C;&#x7B26;&#x53F7;,&#x5FC5;&#x987B;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x8005;&#x53CC;&#x5F15;&#x53F7;&#x5305;&#x88F9;&#x8D77;&#x6765;;<pre><code>  `var test = &quot;&#x4F60;&#x597D;&quot;;`  
  `var test = &quot;123&quot;;`   
</code></pre></li>
<li>3.&#x5E03;&#x5C14;&#x503C;:true&#x548C;false;<pre><code>  `ar bool = true;`  
</code></pre></li>
<li>4.<code>undefined</code>&#x548C;<code>null</code>;    //undefined:&#x58F0;&#x660E;&#x4E0D;&#x8D4B;&#x503C;,&#x62A5;&#x9519;</li>
<li>5.&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;,&#x5BF9;&#x8C61;,&#x51FD;&#x6570;,&#x6570;&#x7EC4;&#x7B49;;</li>
</ul>
<p>&#x8DF3;&#x8F6C;&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">moveon</span>(<span class="hljs-params"></span>)</span>{
                <span class="hljs-keyword">var</span> answer = confirm(<span class="hljs-string">&quot;&#x51C6;&#x5907;&#x597D;&#x4E86;&#x5417;&#xFF1F;&quot;</span>);
                <span class="hljs-keyword">if</span>(answer) <span class="hljs-built_in">window</span>.location=<span class="hljs-string">&quot;http://baidu.com&quot;</span>;
            }
            setTimeout(moveon,<span class="hljs-number">2000</span>);
</code></pre>
<p>&#x5224;&#x65AD;&#x8BED;&#x53E5;:</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> x=<span class="hljs-number">2</span>,y=<span class="hljs-number">3</span>;
        <span class="hljs-keyword">if</span>(!(x==y)){
                alert(<span class="hljs-string">&quot;true&quot;</span>);
        }
        <span class="hljs-keyword">else</span>{
            alert(<span class="hljs-string">&quot;flase&quot;</span>);
        }
</code></pre>
<h3 id="&#x7B2C;&#x4E8C;&#x8282;&#x539F;&#x59CB;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x7B2C;&#x4E8C;&#x8282;&#x539F;&#x59CB;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<h4 id="21-&#x6570;&#x5B57;&#x7C7B;&#x578B;">2.1 &#x6570;&#x5B57;&#x7C7B;&#x578B;</h4>
<h5 id="211&#x6570;&#x5B57;&#x7C7B;&#x578B;">2.1.1&#x6570;&#x5B57;&#x7C7B;&#x578B;</h5>
<ul>
<li>&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;<mark>0-9</mark>;</li>
<li>JAvaScript&#x4E2D;&#x80FD;&#x8868;&#x793A;&#x7684;&#x6574;&#x6570;&#x8303;&#x56F4;&#x5927;&#x5C0F;&#x4E3A;<code>-2^53 ~ 2^53</code>;</li>
<li>&#x221E;&#x65E0;&#x7A77;&#x5927; <code>infinite</code>;</li>
<li><mark>NaN</mark>; Not a Number</li>
<li><mark>typeof (num)</mark>:&#x68C0;&#x6D4B;&#x6570;&#x636E;&#x7C7B;&#x578B; ,&#x62EC;&#x53F7;&#x53EF;&#x6709;&#x53EF;&#x65E0;;<code>console.log(typeof str2);</code></li>
<li><mark>isNaN(num)</mark>:&#x8BE2;&#x95EE;num&#x662F;&#x4E0D;&#x662F; &quot;<mark>&#x4E00;&#x4E2A;&#x4E0D;&#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;&#x7684;&#x503C;?</mark>&quot;;  <ul>
<li>&#x5982;&#x679C;&#x8FD4;&#x56DE;<code>true</code>,&#x8868;&#x793A;<code>num</code>&#x4E0D;&#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;;</li>
<li>&#x5982;&#x679C;&#x8FD4;&#x56DE;<code>false</code>,&#x8868;&#x793A;<code>num</code>&#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;; </li>
</ul>
</li>
</ul>
<p><mark>&#x4EE3;&#x7801;&#x793A;&#x4F8B;</mark>:</p>
<pre><code>var isNumber=4/&quot;a&quot;;
var res = isNaN(isNumber);
console.log(res);
</code></pre><h5 id="212&#x6D6E;&#x70B9;&#x578B;&#x6570;&#x636E;">2.1.2&#x6D6E;&#x70B9;&#x578B;&#x6570;&#x636E;</h5>
<ul>
<li>&#x5E26;&#x5C0F;&#x6570;&#x70B9;&#x7684;&#x6570;&#x636E;&#x53EB;&#x6D6E;&#x70B9;&#x578B;&#x6570;&#x636E;;</li>
<li><mark>%&#x7B26;&#x53F7; &#x8868;&#x793A;&#x6C42;&#x4F59;(&#x53D6;&#x6A21;)</mark><blockquote>
<p>&#x6D6E;&#x70B9;&#x578B;&#x6570;&#x636E;&#x7684;&#x4E0D;&#x786E;&#x5B9A;&#x6027;;     </p>
<pre><code class="lang-JavaScript">  <span class="hljs-keyword">var</span> floatNum1 = <span class="hljs-number">0.3</span>;   
  <span class="hljs-keyword">var</span> floatNum2 = <span class="hljs-number">0.2</span>;  
  <span class="hljs-keyword">var</span> resNum=floatNum1-floatNum2;   
  <span class="hljs-built_in">console</span>.log(resNum);  
  <span class="hljs-built_in">console</span>.log(resNum == <span class="hljs-number">0.1</span>);
</code></pre>
</blockquote>
</li>
</ul>
<h4 id="22-undefined&#x4E0E;null">2.2 undefined&#x4E0E;null</h4>
<p>undefined&#x4E0E;null   </p>
<ul>
<li>&#x5171;&#x540C;&#x70B9;:<mark>&#x90FD;&#x662F;&#x6709;&#x4E00;&#x4E2A;&quot;&#x7A7A;&quot;&#x7684;&#x610F;&#x601D;;&#x8F6C;&#x5316;&#x6210;&#x5E03;&#x5C14;&#x503C;&#x65F6;&#x90FD;&#x8F6C;&#x5316;&#x6210;false;</mark></li>
<li>&#x4E0D;&#x540C;&#x70B9;:<ul>
<li>undefined&#x7ECF;&#x5E38;&#x51FA;&#x73B0;&#x7684;&#x60C5;&#x51B5;&#x662F;:&#x53EA;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x4F46;&#x6CA1;&#x6709;&#x8D4B;&#x503C;&#x65F6;;&#x6B63;&#x5E38;&#x7A0B;&#x5E8F;&#x4E2D;,&#x6211;&#x4EEC;&#x5F88;&#x5C11;&#x4E3B;&#x52A8;&#x7528;&#x5B83;,&#x57FA;&#x672C;&#x4E0A;&#x90FD;&#x662F;&#x5728;&#x62A5;&#x9519;&#x4FE1;&#x606F;&#x91CC;&#x9762;;</li>
<li>null:&#x5B83;&#x662F;&#x4E00;&#x4E2A;&#x5173;&#x952E;&#x5B57;,&#x5B83;&#x4E00;&#x5B9A;&#x7684;&#x4F5C;&#x7528;,&#x4E00;&#x822C;&#x662F;&#x7528;&#x6765;&#x6709;&#x6E05;&#x7A7A;&#x53D8;&#x91CF;&#x6216;&#x8005;&#x5BF9;&#x8C61;&#x65F6;&#x4F7F;&#x7528;;&#x5F53;&#x628A;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x6210;null&#x65F6;,&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x4F1A;&#x88AB;js&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#x56DE;&#x6536;;</li>
</ul>
</li>
</ul>
<p>&#x4EE3;&#x7801;&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> unde;
<span class="hljs-keyword">var</span> test=unde+<span class="hljs-string">&quot;3&quot;</span>;
<span class="hljs-built_in">console</span>.log(test);
test=<span class="hljs-literal">null</span>;<span class="hljs-comment">//&#x6E05;&#x7A7A;test;</span>
<span class="hljs-comment">//&#x5220;&#x4E86;test;</span>
<span class="hljs-keyword">var</span> test2=<span class="hljs-literal">null</span>;
<span class="hljs-built_in">console</span>.log(test2);
</code></pre>
<h4 id="23-&#x5E03;&#x5C14;&#x503C;">2.3 &#x5E03;&#x5C14;&#x503C;</h4>
<ul>
<li>0&#x8868;&#x793A;false;</li>
<li>1&#x8868;&#x793A;true;</li>
<li>&#x4EFB;&#x4F55;JavaScript&#x7684;&#x503C;&#x90FD;&#x8F6C;&#x6362;&#x4E3A;&#x5E03;&#x5C14;&#x503C;;
&#x4EE3;&#x7801;&#x793A;&#x4F8B;:<pre><code class="lang-JavaScript">  <span class="hljs-keyword">var</span> bool=<span class="hljs-literal">true</span>;
  <span class="hljs-keyword">var</span> bool1=<span class="hljs-literal">false</span>;
  <span class="hljs-keyword">if</span>(bool){
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x5199;&#x4F20;&#x5165;&#x9632;&#x901A;&#x8FC7;&#x4E0E;&#x6237;&#x7C4D;&#x95E8;&#x69DB;&quot;</span>);
  }
</code></pre>
</li>
</ul>
<h4 id="24-&#x5B57;&#x7B26;&#x4E32;">2.4 &#x5B57;&#x7B26;&#x4E32;</h4>
<p>&#x5B57;&#x7B26;&#x4E32;&#x7531;&#x96F6;&#x4E2A;&#x6216;&#x8005;&#x591A;&#x4E2A;&#x5B57;&#x7B26;&#x6784;&#x6210;,&#x5B57;&#x7B26;&#x5305;&#x62EC;&#x5B57;&#x6BCD;,&#x6570;&#x5B57;,&#x6807;&#x70B9; &#x7B26;&#x53F7;&#x548C;&#x7A7A;&#x683C;;</p>
<blockquote>
<p>&#x5728;js&#x91CC;&#x9762;,&#x53EF;&#x4EE5;&#x628A;&#x5F15;&#x53F7;&#x770B;&#x4F5C;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x6807;&#x5FD7;;</p>
</blockquote>
<ul>
<li>&#x751A;&#x81F3;&#x53EF;&#x4EE5;&#x5728;&#x5F15;&#x7528;&#x91CC;&#x9762;&#x5199;Unicode&#x7801;;   <ul>
<li><code>var str1=&quot;\u963f&quot;
  console.log(str1);</code></li>
</ul>
</li>
<li>&#x5355;&#x5F15;&#x53F7;&#x91CC;&#x9762;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x53CC;&#x5F15;&#x53F7;,&#x540C;&#x6837;,&#x53CC;&#x5F15;&#x53F7;&#x91CC;&#x9762;&#x4E5F;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x5355;&#x5F15;&#x53F7;;</li>
<li>&#x5982;&#x679C;&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x662F;&#x4E2D;&#x6587;&#x7684;&#x5355;&#x53CC;&#x5F15;&#x53F7;,&#x5219;&#x4F5C;&#x4E3A;&#x4E00;&#x822C;&#x5B57;&#x7B26;&#x5904;&#x7406;;</li>
<li>&#x53CC;&#x5F15;&#x53F7;&#x91CC;&#x9762;&#x662F;&#x4E0D;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x53CC;&#x5F15;&#x53F7;&#x7684;;</li>
<li>&#x4E24;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x7528;+&#x94FE;&#x63A5;&#x8D77;&#x6765;,&#x8868;&#x793A;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x62FC;&#x63A5;;
```JavaScript
var str3 = &quot;&#x4E0B;&#x5F97;&#x53A8;&#x623F;VB&#x4F60;&#x770B;&apos;ghj&apos;&quot;;
console.log(str3);
var str5 = &quot;&#x65B9;&#x63D0;&#x4F9B;&#x7528;&#x6237;&#x63A5;&#x53E3;&#x6CD5;&#x56FD;&#x7EA2;&#x9152;&apos;ghj&apos;&quot;;
var str6 = str3+str5;
console.log(str6);</li>
</ul>
<p>//&#x7528;&#x53D8;&#x91CF;&#x53D6;&#x4EE3;&#x503C;
var str7 = &quot;&#x5927;&#x603B;&#x7BA1;&quot;;
var str8 = &quot;&#x72AF;&#x6843;&#x82B1;&quot;;
console.log(&quot;&#x60F3;&#x5F53;&#x521D;&#x65B9;&#x6CD5;&#x66F4;&#x597D;&apos;&quot;+str7+&quot;&apos;\n&#x501F;&#x53E3;&#x4E86;&#x5206;&#x5DE5;&#x4F1A;&#x5C3D;&#x5FEB;&#x4E86;&quot;);</p>
<pre><code>* &#x53CD;&#x659C;&#x6760;&#x7528;&#x6765;&#x8F6C;&#x4E49;
    * `console.log(&quot;&#x8D85;&#x7EA7;&#x60F3;&#x5728;\\&#x53CC;&#x5F15;&#x53F7;&#x91CC;&#x5D4C;&#x5957;\&quot;&#x53CC;&#x5F15;&#x53F7;\&quot;&quot;);`  
* &lt;mark&gt;Math.random()&lt;/mark&gt;&#x751F;&#x6210;&#x4E00;&#x4E2A;[0,1)&#x7684;&#x968F;&#x673A;&#x6570;;
* &lt;mark&gt;Math.floor()&lt;/mark&gt;&#x5411;&#x4E0B;&#x53D6;&#x6574;;
* &lt;mark&gt;Math.random()*n+m&lt;/mark&gt;;  Math.random()&#x5927;&#x4E8E;m&#x5C0F;&#x4E8E;n;
```JavaScript
console.log(&quot;&#x968F;&#x673A;&#x6570;&quot;+(Math.floor(Math.random()*10+10)));
</code></pre><h3 id="js-&#x7B2C;&#x4E09;&#x8282;-&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;">js &#x7B2C;&#x4E09;&#x8282; &#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<h4 id="31-&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;">3.1 &#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;</h4>
<ul>
<li><p><mark>&#x5BF9;&#x8C61;</mark>:&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x751F;&#x6001;&#x4E2A;&#x4F53;</p>
<ul>
<li>&#x4E00;&#x4E2A;&#x4E2A;&#x4F53;:<ul>
<li>a:&#x63CF;&#x8FF0;&#x4E2A;&#x4F53;&#x7279;&#x5F81;&#x7684;&#x5C5E;&#x6027;;</li>
<li>b:&#x63CF;&#x8FF0;&#x4E2A;&#x4F53;&#x80FD;&#x591F;&#x505A;&#x4E8B;&#x60C5;&#x7684;&#x65B9;&#x6CD5;;</li>
</ul>
</li>
<li>&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x8BF4;&#x5BF9;&#x8C61;&#x5C31;&#x662F;&#x65B9;&#x6CD5;&#x548C;&#x5C5E;&#x6027;&#x7684;&#x7ED3;&#x5408;;</li>
<li>&#x6CE8;&#x610F;:<ul>
<li>1.&#x5BF9;&#x8C61;&#x7684;&#x76F4;&#x63A5;&#x5B69;&#x5B50;&#x53EA;&#x80FD;&#x662F;&#x65B9;&#x6CD5;&#x6216;&#x8005;&#x5C5E;&#x6027;;</li>
<li>2.&#x65B9;&#x6CD5;&#x5C31;&#x662F;&#x4E00;&#x6BB5;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x4E00;&#x5B9A;&#x529F;&#x80FD;&#x7684;js&#x4EE3;&#x7801;;</li>
<li>3.&#x4E66;&#x5199;&#x7684;&#x5177;&#x4F53;&#x8BED;&#x6CD5;&#x662F;:&#x952E;&#x503C;&#x5BF9;&#x7684;&#x5199;&#x6CD5;,&#x952E;&#x540D;(&#x5982;name,age)&#x548C;&#x952E;&#x503C;(&#x5982;&quot;&#x51E4;&#x59D0;&quot;,18)&#x4E4B;&#x95F4;&#x7528;&#x5192;&#x53F7;&#x9694;&#x5F00;,&#x4E0D;&#x540C;&#x5C5E;&#x6027;&#x6216;&#x8005;&#x65B9;&#x6CD5;&#x95F4;&#x7528;&#x9017;&#x53F7;&#x9694;&#x5F00;;</li>
<li>4.&#x975E;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;,&#x952E;&#x540D;&#x7684;&#x53CC;&#x5F15;&#x53F7;&#x53EF;&#x4EE5;&#x4E0D;&#x5199;;</li>
<li>5.&#x53EF;&#x4EE5;&#x628A;{}&#x770B;&#x4F5C;&#x5BF9;&#x8C61;&#x7684;&#x6807;&#x8BC6;;</li>
</ul>
</li>
</ul>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">
  <span class="hljs-keyword">var</span> aft_geia = {
      <span class="hljs-string">&quot;name&quot;</span>:<span class="hljs-string">&quot;&#x516C;&#x76CA;&quot;</span>,
      <span class="hljs-string">&quot;age&quot;</span>:<span class="hljs-number">18</span>,
      <span class="hljs-string">&quot;skill&quot;</span>:<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
          <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x534A;&#x591C;&#x6D3B;&#x52A8;&#x6B63;&#x5728;&#x8FDB;&#x884C;&#x4E2D;.....&quot;</span>)
      },
      fav:<span class="hljs-string">&quot;sg&quot;</span>
  };
  aft_geia.sex=<span class="hljs-string">&quot;vfby&quot;</span>;
  <span class="hljs-built_in">console</span>.log(aft_geia);
  <span class="hljs-built_in">console</span>.log(aft_geia.name);
  aft_geia.skill();
</code></pre>
</li>
<li><mark>&#x6570;&#x7EC4;</mark>:&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x4E00;&#x8F86;&#x591A;&#x8282;&#x7684;&#x706B;&#x8F66;,&#x6BCF;&#x4E00;&#x8282;&#x90FD;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x5BB9;&#x5668;(&#x53D8;&#x91CF;),&#x6BCF;&#x4E2A;&#x5BB9;&#x5668;&#x90FD;&#x53EF;&#x4EE5;&#x653E;&#x4EFB;&#x610F;&#x6570;&#x636E;&#x7C7B;&#x578B;;<ul>
<li>&#x5177;&#x4F53;&#x7684;&#x8BED;&#x6CD5;&#x4E3A;:&#x5728;[]&#x5185;&#x4E66;&#x5199;&#x6570;&#x7EC4;&#x7684;&#x5404;&#x4E2A;&#x5143;&#x7D20;,&#x5143;&#x7D20;&#x4E4B;&#x95F4;&#x7528;&#x9017;&#x53F7;&#x9694;&#x5F00;;</li>
<li>&#x83B7;&#x53D6;&#x6570;&#x7EC4;&#x91CC;&#x9762;&#x7684;&#x5143;&#x7D20;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x901A;&#x8FC7;&#x4E0B;&#x6807;&#x503C;&#x62FF;&#x5230;&#x7684;</li>
<li>&#x6CE8;&#x610F;: &#x4E0B;&#x6807;&#x503C;&#x662F;&#x4ECE;0&#x5F00;&#x59CB;&#x7684;;<ul>
<li>&#x5177;&#x4F53;&#x8BED;&#x6CD5;&#x4E3A;<code>arr[0];arr[1];arr[2]...</code></li>
</ul>
</li>
</ul>
</li>
</ul>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> arr = [<span class="hljs-string">&quot;1&quot;</span>,<span class="hljs-number">666</span>,{name:<span class="hljs-string">&quot;bnm&quot;</span>}];
        <span class="hljs-keyword">var</span> ran = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random()*<span class="hljs-number">3</span>);
        <span class="hljs-built_in">console</span>.log(arr[ran]);
</code></pre>
<ul>
<li><mark>&#x51FD;&#x6570;</mark><ul>
<li>&#x628A;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x529F;&#x80FD;&#x7684;&#x591A;&#x884C;&#x4EE3;&#x7801;&#x5C01;&#x88C5;&#x5728;&#x4E00;&#x8D77;;</li>
<li>&#x5177;&#x4F53;&#x7684;&#x8BED;&#x6CD5;: &#x901A;&#x8FC7;&#x5173;&#x952E;&#x5B57;function&#x58F0;&#x660E;<blockquote>
<p>function &#x51FD;&#x6570;&#x540D;(){</p>
<pre><code>   //&#x8981;&#x6267;&#x884C;&#x67D0;&#x529F;&#x80FD;&#x7684;&#x5177;&#x4F53;&#x4EE3;&#x7801;
</code></pre><p>   }</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">selectGirl</span>(<span class="hljs-params"></span>)</span>{
                <span class="hljs-keyword">var</span> arr1 = [<span class="hljs-string">&quot;&#x5B98;&#x6D77;&#x8857;&#x53E3;&#x91CC;&quot;</span>,<span class="hljs-string">&quot;&#x60E9;&#x7F5A;&#x519B;&#x670D;&#x97EC;&#x5149;&#x517B;&#x6666;&#x53EB;&quot;</span>,<span class="hljs-string">&quot;&#x65B0;&#x7684;&#x6295;&#x5165;&#x8FD4;&#x56DE;&#x952E;&quot;</span>,<span class="hljs-string">&quot;&#x5730;&#x4E0B;&#x57CE;&#x98DE;&#x5929;&#x72D7;&#x4E00;&#x4F1A;&#x5427;&quot;</span>,<span class="hljs-string">&quot;&#x7684;&#x6CD5;&#x56FD;&#x7EA2;&#x9152;&quot;</span>];
                <span class="hljs-keyword">var</span> arr2 = [<span class="hljs-string">&quot;&#x4E0B;&#x5F97;&#x53A8;&#x623F;&#x6839;&#x672C;&#x80FD;&#x529B;&quot;</span>,<span class="hljs-string">&quot;&#x5B8C;&#x6210;&#x53D1;&#x4E2A;&#x90AE;&#x4EF6;&quot;</span>,<span class="hljs-string">&quot;&#x65B0;&#x7684;&#x6295;&#x5165;&#x8FD4;&#x56DE;&#x952E;&quot;</span>,<span class="hljs-string">&quot;&#x91C7;&#x8BBF;&#x7A3F;&#x770B;&quot;</span>,<span class="hljs-string">&quot;&#x624D;&#x53D1;&#x73B0;&#x8272;&#x7684;&#x4EBA;&#x4F0F;&#x7279;&#x52A0;&quot;</span>];
                <span class="hljs-keyword">var</span> ran = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random()*<span class="hljs-number">5</span>);
                <span class="hljs-built_in">document</span>.write(arr1[ran]);
                <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 style=&apos;text-align: center;&apos;&gt;&quot;</span>+arr1[ran]+<span class="hljs-string">&quot;&amp;nbsp;&#x563F;&#x563F;&#x563F;&lt;span style=&apos;font-size: 16px;&apos;&gt;&quot;</span>+arr2[ran]+<span class="hljs-string">&quot;&lt;/span&gt;&lt;/h1&gt;&quot;</span>);
            }
            selectGirl();
            selectGirl();
            selectGirl();
            <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> selectGirl);
</code></pre>
<h4 id="32&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x7684;&#x5B58;&#x50A8;">3.2&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x7684;&#x5B58;&#x50A8;</h4>
<blockquote>
<p>&#x5982;&#x679C;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x90A3;&#x4E48;&#x53D8;&#x91CF;&#x5B58;&#x50A8;&#x7684;&#x4EC5;&#x4EC5;&#x662F;&#x6307;&#x5411;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x6307;&#x9488;(&#x8DEF;&#x5F84;)
&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">            <span class="hljs-keyword">var</span> str1 = <span class="hljs-string">&quot;&#x6DA6;&#x53D1;&#x94C1;&#x89C2;&#x97F3;&#x80E1;&#x5EFA;&#x5E73;&quot;</span>;
            <span class="hljs-keyword">var</span> str2 = <span class="hljs-string">&quot;&#x6DA6;&#x53D1;&#x94C1;&#x89C2;&#x97F3;&#x80E1;&#x5EFA;&#x5E73;&quot;</span>;
            <span class="hljs-keyword">var</span> obj1 = {name:<span class="hljs-string">&quot;&#x94C1;&#x89C2;&#x97F3;&quot;</span>};
            <span class="hljs-keyword">var</span> obj2 = {name:<span class="hljs-string">&quot;&#x94C1;&#x89C2;&#x97F3;&quot;</span>};
            <span class="hljs-built_in">console</span>.log(str1 == str2);<span class="hljs-comment">//true</span>
            <span class="hljs-built_in">console</span>.log(obj1 == obj2);<span class="hljs-comment">//false</span>
            <span class="hljs-keyword">var</span> obj11=obj1;
            obj11.name=<span class="hljs-string">&quot;&#x5982;&#x7CAA;&#x571F;&quot;</span>;<span class="hljs-comment">//obj1&#x4E5F;&#x4F1A;&#x8DDF;&#x7740;&#x6539;&#x53D8;</span>
            <span class="hljs-built_in">console</span>.log(obj1);
            <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> obj1);
</code></pre>
</blockquote>
<h3 id="&#x7B2C;&#x56DB;&#x8282;-&#x8FD0;&#x7B97;">&#x7B2C;&#x56DB;&#x8282; &#x8FD0;&#x7B97;</h3>
<h4 id="41-&#x6570;&#x636E;&#x7C7B;&#x578B;&#x95F4;&#x7684;&#x8F6C;&#x5316;">4.1 &#x6570;&#x636E;&#x7C7B;&#x578B;&#x95F4;&#x7684;&#x8F6C;&#x5316;</h4>
<ul>
<li><p>4.1.1&#x9690;&#x5F0F;&#x8F6C;&#x5316;:&#x7CFB;&#x7EDF;&#x6839;&#x636E;&#x9700;&#x6C42;&#x7684;&#x81EA;&#x52A8;&#x8F6C;&#x6362;
&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">if</span>(<span class="hljs-number">123</span>){
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;if&#x6761;&#x4EF6;&#x4E3A;&#x771F;&#x65F6;&#x6267;&#x884C;...&quot;</span>);
}
<span class="hljs-keyword">var</span> str=<span class="hljs-string">&quot;nihao&quot;</span>;
<span class="hljs-built_in">console</span>.log(str.length)
</code></pre>
</li>
<li><p>4.1.2&#x6570;&#x5B57;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x89C4;&#x5219;,&#x4F8B;&#x5982;1=&gt;&quot;1&quot;;</p>
<ul>
<li>&#x65B9;&#x6CD5;:&#x901A;&#x8FC7;&#x8C03;&#x7528;&#x6570;&#x5B57;&#x5BF9;&#x8C61;&#x7684;toFixed(par)&#x65B9;&#x6CD5;,&#x8FD9;&#x4E2A;&#x4E00;&#x4E2A;&#x53C2;&#x6570;,&#x53C2;&#x6570;&#x51B3;&#x5B9A;&#x4E86;&#x4FDD;&#x7559;&#x5C0F;&#x6570;&#x70B9;&#x7684;&#x4F4D;&#x6570;;</li>
</ul>
</li>
</ul>
<p>&#x793A;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> num=<span class="hljs-number">3.1415926</span>;
<span class="hljs-keyword">var</span> str = num.toFixed(<span class="hljs-number">2</span>);
<span class="hljs-built_in">console</span>.log(str);
</code></pre>
<ul>
<li>4.1.3&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x6570;&#x5B57;&quot;123&quot;=&gt;123;&quot;abc&quot;=&gt;NaN;<ul>
<li>&#x65B9;&#x6CD5;:parseInt()&#x548C;parseFloat();<br><code>var num = parseInt(&quot;354abc12a&quot;);</code><br><code>console.log(num);//354</code>  </li>
</ul>
</li>
</ul>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> test1=<span class="hljs-built_in">parseInt</span>(<span class="hljs-string">&quot;12&quot;</span>,<span class="hljs-number">2</span>)<span class="hljs-comment">//&#x8FDB;&#x5236;&#x8F6C;&#x6362;</span>
            <span class="hljs-built_in">console</span>.log(test1);
</code></pre>
<h5 id="414-tostring">4.1.4 toString</h5>
<blockquote>
<p>&#x9664;&#x4E86;null&#x548C;undefined&#x5916;,&#x4EFB;&#x4F55;&#x503C;&#x90FD;&#x6709;toString(&#x65B9;&#x6CD5;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;)</p>
</blockquote>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> bool=<span class="hljs-literal">true</span>;
<span class="hljs-keyword">var</span> bool_str = bool.toString();
<span class="hljs-built_in">console</span>.log(bool_str);
<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> bool_str);
</code></pre>
<h6 id="&#x8F6C;&#x6362;&#x4E3A;&#x5E03;&#x5C14;&#x503C;false&#x7684;&#x6709;undefinednull0nan&#x5176;&#x4ED6;&#x7684;&#x90FD;&#x4E3A;true">&#x8F6C;&#x6362;&#x4E3A;&#x5E03;&#x5C14;&#x503C;false&#x7684;&#x6709;:undefined/null/0/NaN/&quot;&quot;;&#x5176;&#x4ED6;&#x7684;&#x90FD;&#x4E3A;true</h6>
<ul>
<li>&#x5E03;&#x5C14;&#x503C;&#x8F6C;&#x6570;&#x5B57;<pre><code class="lang-JavaScript">  <span class="hljs-keyword">var</span> num = <span class="hljs-literal">true</span> - <span class="hljs-number">2</span>;<span class="hljs-comment">//&#x7ED3;&#x679C;&#x4E3A;0;&#x56E0;&#x4E3A;true&#x8F6C;&#x6362;&#x4E3A;1;</span>
  <span class="hljs-built_in">console</span>.log(num);
  <span class="hljs-keyword">if</span>(<span class="hljs-literal">NaN</span>){
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x4F1A;&#x6267;&#x884C;&quot;</span>);
  }
</code></pre>
</li>
</ul>
<h4 id="42&#x8FD0;&#x7B97;&#x7B26;">4.2&#x8FD0;&#x7B97;&#x7B26;</h4>
<p>&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</p>
<blockquote>
<p>+,-,*,/,%</p>
</blockquote>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">    <span class="hljs-keyword">var</span> a=<span class="hljs-number">11.3</span>;
    <span class="hljs-keyword">var</span> res= a-<span class="hljs-number">1</span>+<span class="hljs-number">2</span>-<span class="hljs-number">3</span>*<span class="hljs-number">5</span>/<span class="hljs-number">2</span>;
    <span class="hljs-built_in">console</span>.log(res);
    <span class="hljs-keyword">var</span> res= a%<span class="hljs-number">3</span>;
    <span class="hljs-built_in">console</span>.log(res);
</code></pre>
<ul>
<li>&#x81EA;&#x589E;++    a++/++a;<ul>
<li>&#x5982;&#x679C;&#x53EA;&#x662F;&#x5355;&#x7EAF;&#x7684;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x81EA;&#x589E;,&#x90A3;&#x4E48;a++&#x4E0E;++a&#x6CA1;&#x6709;&#x533A;&#x522B;;&#x4F46;&#x662F;&#x5982;&#x679C;&#x628A;&#x81EA;&#x589E;&#x8FD0;&#x7B97;&#x653E;&#x5230;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x6267;&#x884C;&#x73AF;&#x5883;&#x91CC;&#x9762;,&#x90A3;&#x4E48;a++&#x4F1A;&#x5148;&#x6267;&#x884C;&#x8BED;&#x53E5;,&#x540E;&#x81EA;&#x589E;,&#x800C;++a&#x4F1A;&#x5148;&#x81EA;&#x589E;,&#x518D;&#x6267;&#x884C;&#x5177;&#x4F53;&#x7684;&#x8BED;&#x53E5;;</li>
</ul>
</li>
<li>&#x81EA;&#x51CF;--<h4 id="43-&#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;">4.3 &#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;</h4>
&#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;:&#x6709;&#x8FD4;&#x56DE;&#x503C;;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E3A;&#x5E03;&#x5C14;&#x503C;;</li>
<li><blockquote>
<p>&lt; &gt;= &lt;= </p>
</blockquote>
</li>
<li>== &#x6BD4;&#x8F83;&#x662F;&#x5426;&#x76F8;&#x7B49;</li>
<li>=== &#x6BD4;&#x8F83;&#x662F;&#x5426;&#x5B8C;&#x5168;&#x76F8;&#x7B49;;&#x548C;==&#x533A;&#x522B;&#x5728;&#x4E8E;,&#x4E0D;&#x4EC5;&#x6BD4;&#x8F83;&#x503C;&#x8FD8;&#x8981;&#x6BD4;&#x8F83;&#x6570;&#x636E;&#x7C7B;&#x578B;;</li>
<li>!= &#x4E0D;&#x7B49;&#x4E8E;</li>
<li>!== &#x5B8C;&#x5168;&#x4E0D;&#x7B49;&#x4E8E;;&#x6BD4;&#x8F83;&#x7684;&#x4E24;&#x4E2A;&#x503C;,&#x5C31;&#x7B97;&#x503C;&#x76F8;&#x7B49;,&#x7C7B;&#x578B;&#x4E0D;&#x540C;,&#x4E5F;&#x662F;&#x4E0D;&#x540C;,&#x6240;&#x4EE5;&#x4F1A;&#x8FD4;&#x56DE;true;</li>
</ul>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">    <span class="hljs-keyword">var</span> a=<span class="hljs-number">10</span>,
        b=<span class="hljs-number">5</span>,
        res=a&gt;b;
    <span class="hljs-keyword">var</span> res=a&lt;b;
    <span class="hljs-keyword">var</span> res=a==b;
    <span class="hljs-built_in">console</span>.log(res);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&quot;</span> == <span class="hljs-string">&quot;a&quot;</span>);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> == <span class="hljs-string">&quot;1&quot;</span>);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> === <span class="hljs-string">&quot;1&quot;</span>);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> !== <span class="hljs-string">&quot;1&quot;</span>);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> != <span class="hljs-string">&quot;1&quot;</span>);
</code></pre>
<h3 id="&#x7B2C;&#x4E94;&#x8282;-&#x8FD0;&#x7B97;&#x7B26;if&#x5FAA;&#x73AF;">&#x7B2C;&#x4E94;&#x8282; &#x8FD0;&#x7B97;&#x7B26;,if,&#x5FAA;&#x73AF;</h3>
<h4 id="51-&#x8FD0;&#x7B97;&#x7B26;">5.1 &#x8FD0;&#x7B97;&#x7B26;</h4>
<h5 id="511&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;">5.1.1&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</h5>
<p><mark>&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;:</mark> + , - , * , / , % ;</p>
<h5 id="512-&#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;">5.1.2 &#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;</h5>
<p><mark>&#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;:</mark> &gt; , &lt; , = , == , === , != , !==;</p>
<h5 id="513-&#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F;">5.1.3 &#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F;</h5>
<p><mark>&#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F; :</mark>  || , &amp;&amp; , ! ; &#x8FD4;&#x56DE;&#x503C;&#x4E5F;&#x662F;&#x5E03;&#x5C14;&#x503C;;</p>
<ul>
<li>&apos;&amp;&amp;&apos; &#x903B;&#x8F91;&#x4E0E;(&#x4E14;),&#x5F53;&#x64CD;&#x4F5C;&#x7684;&#x4E24;&#x4E2A;&#x6570;&#x636E;&#x540C;&#x65F6;&#x4E3A;true,&#x5219;&#x8FD4;&#x56DE;true; &quot;&#x4E00;&#x5047;&#x5373;&#x5047;&quot;;<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> test1=<span class="hljs-literal">true</span>,
          test2=<span class="hljs-literal">true</span>,
          test3=<span class="hljs-literal">false</span>;
      <span class="hljs-built_in">console</span>.log(test1&amp;&amp;test2);
</code></pre>
</li>
<li>&apos;||&apos; &#x903B;&#x8F91;&#x6216; ,&#x53EA;&#x8981;&#x64CD;&#x4F5C;&#x7684;&#x6570;&#x636E;&#x6709;&#x4E00;&#x4E2A;&#x662F;true&#x5219;&#x8FD4;&#x56DE;true; &quot;&#x4E00;&#x771F;&#x5373;&#x771F;&quot;;<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> a = <span class="hljs-number">10</span>,b=<span class="hljs-number">5</span>,c=<span class="hljs-number">12</span>;
      <span class="hljs-built_in">console</span>.log(a&gt;b||a&gt;c);
</code></pre>
</li>
<li>&apos;!&apos; &#x903B;&#x8F91;&#x975E;,&#x53D6;&#x53CD; <pre><code class="lang-JavaScript">      <span class="hljs-built_in">console</span>.log(!<span class="hljs-number">0</span>);
      <span class="hljs-keyword">var</span> test4=<span class="hljs-string">&quot;aa&quot;</span>;
      <span class="hljs-built_in">console</span>.log(!!test4);<span class="hljs-comment">//&#x8F6C;&#x6362;&#x4E3A;&#x5E03;&#x5C14;&#x503C;;</span>
</code></pre>
</li>
<li>&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x6DF1;&#x5165;&#x7406;&#x89E3;<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> x=<span class="hljs-number">5</span>;
      x&lt;<span class="hljs-number">3</span>||<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x8FD0;&#x884C;&#x4E86;&quot;</span>);
      <span class="hljs-keyword">var</span> isValue=<span class="hljs-string">&quot;&#x90FD;&#x53D1;&#x8FC7;&#x4E00;&#x4EFD;&#x66F4;&#x597D;&quot;</span>, 
          test=isValue||<span class="hljs-number">5</span>;
      <span class="hljs-built_in">console</span>.log(test);
      <span class="hljs-keyword">var</span> test2=x&gt;<span class="hljs-number">4</span>&amp;&amp;<span class="hljs-string">&quot;&#x5927;&#x6DA6;&#x53D1;&#x6258;&quot;</span>;
      <span class="hljs-built_in">console</span>.log(test2);
</code></pre>
<h5 id="513--&#x4E09;&#x5143;&#x8FD0;&#x7B97;&#x7B26;">5.1.3  &#x4E09;&#x5143;&#x8FD0;&#x7B97;&#x7B26;</h5>
<mark>&#x4E09;&#x5143;&#x8FD0;&#x7B97;&#x7B26;:</mark> &#x6761;&#x4EF6;&#x5224;&#x65AD; &quot; ? &quot; &#x8BED;&#x53E5;1&#x6267;&#x884C;,&quot; : &quot; &#x8BED;&#x53E5;2&#x6267;&#x884C;;   <pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x6210;&#x7EE9;60 &#x53CA;&#x683C;,70-80 &#x826F;&#x597D;,80 &#x4F18;&#x79C0;;</span>
      <span class="hljs-keyword">var</span> grade=<span class="hljs-number">30</span>;
      <span class="hljs-keyword">var</span> grade=<span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random()*<span class="hljs-number">101</span>);
      grade&gt;=<span class="hljs-number">80</span> ? <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x4F18;&#x79C0;&quot;</span>):grade&gt;=<span class="hljs-number">70</span>?<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x826F;&#x597D;&quot;</span>):grade&gt;=<span class="hljs-number">60</span>?<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x53CA;&#x683C;&quot;</span>):<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x4E0D;&#x53CA;&#x683C;&quot;</span>);
</code></pre>
</li>
</ul>
<h4 id="52-if-&#x5224;&#x65AD;&#x8BED;&#x53E5;">5.2 if &#x5224;&#x65AD;&#x8BED;&#x53E5;</h4>
<h5 id="521-if">5.2.1 if</h5>
<p><mark>if&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x8BED;&#x53E5;</mark></p>
<pre><code class="lang-JavaScript">         <span class="hljs-keyword">if</span>(&#x5224;&#x65AD;&#x6761;&#x4EF6;){
             <span class="hljs-comment">//&#x6761;&#x4EF6;&#x6210;&#x7ACB;&#x65F6;&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;;</span>
         }<span class="hljs-keyword">else</span>{
             <span class="hljs-comment">//&#x6761;&#x4EF6;&#x4E0D;&#x6210;&#x7ACB;&#x662F;&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;;</span>
         }
</code></pre>
<p><mark>&#x793A;&#x4F8B;:</mark></p>
<pre><code class="lang-JavaScript">        <span class="hljs-keyword">var</span> grade=<span class="hljs-number">20</span>;
        <span class="hljs-keyword">if</span>(grade&gt;=<span class="hljs-number">80</span>){
            <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x4F18;&#x79C0;&lt;/h1&gt;&quot;</span>);
        }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(grade&gt;=<span class="hljs-number">70</span>){
            <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x826F;&#x597D;&lt;/h1&gt;&quot;</span>);
        }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(grade&gt;=<span class="hljs-number">60</span>){
            <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x53CA;&#x683C;&lt;/h1&gt;&quot;</span>);
        }<span class="hljs-keyword">else</span>{
            <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x4E0D;&#x53CA;&#x683C;&lt;/h1&gt;&quot;</span>);
        }
</code></pre>
<h5 id="522-switch">5.2.2 switch</h5>
<p><mark>switch&#x4E2D;&#x503C;&#x7684;&#x5339;&#x914D;&#x65F6;&#x6309;===&#x6309;&#x65F6;&#x76F8;&#x7B49;&#x5339;&#x914D;&#x7684;;</mark></p>
<pre><code class="lang-JavaScript">        <span class="hljs-keyword">switch</span>(&#x503C;){
             <span class="hljs-keyword">case</span> &#x503C;<span class="hljs-number">1</span>:&#x6267;&#x884C;&#x8BED;&#x53E5;<span class="hljs-number">1</span>;<span class="hljs-keyword">break</span>;
             <span class="hljs-keyword">case</span> &#x503C;<span class="hljs-number">2</span>:&#x6267;&#x884C;&#x8BED;&#x53E5;<span class="hljs-number">2</span>;<span class="hljs-keyword">break</span>;
             ....
             <span class="hljs-keyword">default</span>:&#x6267;&#x884C;&#x9ED8;&#x8BA4;&#x8BED;&#x53E5;;
        }
</code></pre>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">            <span class="hljs-keyword">var</span> arr=[<span class="hljs-string">&quot;aft_girl1&quot;</span>,<span class="hljs-string">&quot;aft_girl2&quot;</span>,<span class="hljs-string">&quot;aft_girl3&quot;</span>];
            <span class="hljs-keyword">var</span> ran=<span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random()*<span class="hljs-number">4</span>);
            <span class="hljs-keyword">switch</span>(arr[ran]){
                <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;aft_girl1&quot;</span>:<span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x554A;&#x554A;&#x554A;&#x554A;&#x554A;&#x554A;&lt;/h1&gt;&quot;</span>);<span class="hljs-keyword">break</span>;
                <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;aft_girl2&quot;</span>:<span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x563F;&#x563F;&#x563F;&#x563F;&#x563F;&#x563F;&lt;/h1&gt;&quot;</span>);<span class="hljs-keyword">break</span>;
                <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;aft_girl3&quot;</span>:<span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x54E6;&#x54E6;&#x54E6;&#x54E6;&#x54E6;&#x54E6;&lt;/h1&gt;&quot;</span>);<span class="hljs-keyword">break</span>;
                <span class="hljs-keyword">default</span>:<span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;h1 align=center&gt;&#x65E0;&#x529B;&lt;/h1&gt;&quot;</span>);
            }
</code></pre>
<h4 id="53-&#x5FAA;&#x73AF;">5.3 &#x5FAA;&#x73AF;</h4>
<h5 id="531-for-&#x5FAA;&#x73AF;">5.3.1 for &#x5FAA;&#x73AF;</h5>
<p><mark>for&#x5FAA;&#x73AF;&#x8BED;&#x53E5;:</mark></p>
<pre><code class="lang-JavaScript">         <span class="hljs-keyword">for</span>(&#x521D;&#x59CB;&#x5316;&#x6761;&#x4EF6;;&#x5224;&#x65AD;&#x6761;&#x4EF6;;&#x8BA1;&#x6B65;&#x5668;&#x66F4;&#x65B0;){
             <span class="hljs-comment">//&#x6BCF;&#x4E00;&#x6B21;&#x5FAA;&#x73AF;&#x8981;&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;;</span>
         }

        <span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;
        <span class="hljs-keyword">for</span>(;;){
            <span class="hljs-built_in">console</span>.log(i);
            i++;
            <span class="hljs-keyword">if</span>(i&gt;=<span class="hljs-number">5</span>){
                <span class="hljs-keyword">break</span>;
            }
        }
</code></pre>
<blockquote>
<p>&#x7A0B;&#x5E8F;&#x6267;&#x884C;&#x5230;for&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x65F6;,&#x9996;&#x5148;&#x6267;&#x884C;&#x521D;&#x59CB;&#x5316;&#x6761;&#x4EF6;,&#x7136;&#x540E;&#x6267;&#x884C;&#x5224;&#x65AD;&#x6761;&#x4EF6;,&#x7136;&#x540E;&#x6267;&#x884C;{}&#x91CC;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5757;,&#x7136;&#x540E;&#x6267;&#x884C;&#x8BA1;&#x6B65;&#x5668;&#x66F4;&#x65B0;,&#x7136;&#x540E;&#x518D;&#x6B21;&#x6267;&#x884C;&#x5224;&#x65AD;&#x6761;&#x4EF6;,&#x7136;&#x540E;&#x518D;&#x6B21;&#x6267;&#x884C;{}&#x91CC;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5757;,&#x7136;&#x540E;&#x518D;&#x6B21;&#x6267;&#x884C;&#x8BA1;&#x6B65;&#x5668;&#x66F4;&#x65B0;,&#x7136;&#x540E;&#x518D;&#x6B21;&#x6267;&#x884C;&#x5224;&#x65AD;&#x6761;&#x4EF6;,&#x7136;&#x540E;&#x518D;&#x6B21;&#x6267;&#x884C;{}&#x91CC;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5757;....&#x76F4;&#x5230;&#x5224;&#x65AD;&#x6761;&#x4EF6;&#x8FD4;&#x56DE;false;</p>
</blockquote>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">1</span>;i&lt;<span class="hljs-number">8</span>;i++){
            <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> j=<span class="hljs-number">0</span>;j&lt;i;j++){
                <span class="hljs-keyword">if</span>(j==<span class="hljs-number">0</span>||j==i-<span class="hljs-number">1</span>){
                    <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;*&amp;nbsp;&quot;</span>);
                }<span class="hljs-keyword">else</span>{
                    <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&amp;nbsp;&quot;</span>);
                }
            }
            <span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&lt;br/&gt;&quot;</span>);
        }
</code></pre>
<ul>
<li>&#x5FAA;&#x73AF;&#x91CC;&#x9762;&#x7684;break&#x4E0E;continue<ul>
<li>&#x5F53;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x9047;&#x5230;break&#x65F6;,&#x5C31;&#x4F1A;&#x8DF3;&#x51FA;&#x5FAA;&#x73AF;,&#x6267;&#x884C;&#x540E;&#x7EED;&#x8BED;&#x53E5;;<pre><code class="lang-JavaScript">  <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-number">10</span>;i++){
      <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> j=<span class="hljs-number">0</span>;j&lt;<span class="hljs-number">5</span>;j++){
          <span class="hljs-keyword">if</span>(j==<span class="hljs-number">3</span>){
              <span class="hljs-keyword">break</span>;
          }
          <span class="hljs-built_in">console</span>.log(i,j);
      }
  }
</code></pre>
</li>
</ul>
</li>
<li>&#x5F53;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x9047;&#x5230;continue&#x65F6;,&#x5C31;&#x4F1A;&#x8DF3;&#x51FA;&#x5F53;&#x6B21;&#x5FAA;&#x73AF;,&#x6267;&#x884C;&#x4E0B;&#x4E00;&#x6B21;&#x5FAA;&#x73AF;;   <pre><code class="lang-JavaScript">      <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-number">10</span>;i++){
          <span class="hljs-keyword">if</span>(i==<span class="hljs-number">5</span>){
              <span class="hljs-keyword">continue</span>;
          }
          <span class="hljs-built_in">document</span>.write(i);        
      }
</code></pre>
<h5 id="532-while-&#x5FAA;&#x73AF;">5.3.2 while &#x5FAA;&#x73AF;</h5>
<mark>while&#x5FAA;&#x73AF;:</mark>
&#x5148;&#x5224;&#x65AD;&#x5FAA;&#x73AF;,&#x662F;&#x5426;&#x6EE1;&#x8DB3;,&#x5982;&#x679C;&#x6EE1;&#x8DB3;&#x5219;&#x6267;&#x884C;{}&#x91CC;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5757;,&#x76F4;&#x81F3;&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x4E0D;&#x6210;&#x7ACB;<pre><code class="lang-JavaScript">       <span class="hljs-keyword">while</span>(){
           <span class="hljs-comment">//&#x5FAA;&#x73AF;&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;</span>
       }
</code></pre>
&#x793A;&#x4F8B;:<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> x=<span class="hljs-number">10</span>;
      <span class="hljs-keyword">while</span>(x&lt;<span class="hljs-number">20</span>){
          <span class="hljs-built_in">console</span>.log(x);
          x++;
          <span class="hljs-comment">//window.open(&quot;http://www.baidu.com&quot;);</span>
      }
</code></pre>
<h5 id="533-dowhite-&#x5FAA;&#x73AF;">5.3.3 do...white &#x5FAA;&#x73AF;</h5>
<mark>do...while&#x5FAA;&#x73AF;:</mark>
```JavaScript<pre><code>   do{
       //&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;
   }while(&#x5FAA;&#x73AF;&#x6761;&#x4EF6;)
</code></pre></li>
</ul>
<pre><code>* do...white&#x5FAA;&#x73AF;&#x548C;white&#x5FAA;&#x73AF;&#x5F88;&#x50CF;,&#x4F46;&#x662F;do/while&#x5FAA;&#x73AF;&#x81F3;&#x5C11;&#x6267;&#x884C;&#x4E00;&#x6B21;do&#x540E;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5757;;
```JavaScript
        var x=30;
        do{
            console.log(&quot;x&quot;);
            x--;
        }while(x&lt;20);
</code></pre><ul>
<li>&#x6269;&#x5C55;<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> obj={
          name:<span class="hljs-string">&quot;&#x597D;&quot;</span>,
          age:<span class="hljs-number">18</span>,
          height:<span class="hljs-number">144</span>,
          deight:<span class="hljs-number">200</span>
      };
      <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> k <span class="hljs-keyword">in</span> obj){
          <span class="hljs-built_in">console</span>.log(k,obj[k]);
      }
</code></pre>
<h5 id="534-alert&#x4E09;&#x5144;&#x5F1F;">5.3.4 alert&#x4E09;&#x5144;&#x5F1F;</h5>
</li>
<li>alert &#x7B80;&#x5355;&#x7684;&#x4E00;&#x4E2A;&#x5F39;&#x51FA;&#x6846;;<code>alert(&quot;&#x53D1;&#x56FE;&quot;);</code></li>
<li>confirm &#x786E;&#x5B9A;&#x5F39;&#x51FA;&#x6846;,&#x7528;&#x6237;&#x70B9;&#x51FB;&#x786E;&#x5B9A;&#x8FD4;&#x56DE;&#x5E03;&#x5C14;&#x503C;true,&#x53D6;&#x6D88;&#x8FD4;&#x56DE;false;<code>confirm(&quot;&#x89C4;&#x5212;&#x5C40;&#x5F53;&#x7136;&#x540C;&#x610F;&quot;);</code></li>
<li>prompt &#x7528;&#x4E8E;&#x83B7;&#x53D6;&#x7528;&#x6237;&#x8F93;&#x5165;,&#x70B9;&#x51FB;&#x786E;&#x5B9A;&#x8FD4;&#x56DE;&#x7528;&#x6237;&#x8F93;&#x5165;&#x7684;&#x5185;&#x5BB9;,&#x70B9;&#x51FB;&#x53D6;&#x6D88;&#x8FD4;&#x56DE;null;<code>prompt(&quot;&#x7FFB;&#x8BD1;&quot;,&quot;&#x8D35;&quot;,2);</code></li>
</ul>
<h3 id="&#x7B2C;&#x516D;&#x8282;-&#x51FD;&#x6570;">&#x7B2C;&#x516D;&#x8282; &#x51FD;&#x6570;</h3>
<h4 id="61-&#x58F0;&#x660E;&#x51FD;&#x6570;">6.1 &#x58F0;&#x660E;&#x51FD;&#x6570;</h4>
<pre><code class="lang-JavaScript"><span class="hljs-function"><span class="hljs-keyword">function</span> &#x51FD;&#x6570;&#x540D;(<span class="hljs-params">canshu</span>)</span>{<span class="hljs-comment">//&#x8FD9;&#x91CC;&#x7684;name&#x79F0;&#x4E3A;&#x5F62;&#x53C2;;</span>
    <span class="hljs-comment">//&#x5B9E;&#x73B0;&#x529F;&#x80FD;&#x7684;&#x4EE3;&#x7801;</span>
}
&#x51FD;&#x6570;&#x540D;(canshu);<span class="hljs-comment">//&#x8C03;&#x7528;&#x65F6;&#x4F20;&#x8FDB;&#x53BB;&#x7684;&#x53C2;&#x6570;&#x79F0;&#x4E3A;&quot;&#x5B9E;&#x53C2;&quot;;</span>
</code></pre>
<ul>
<li>&#x51FD;&#x6570;&#x7684;&#x4F7F;&#x7528;&#x5206;&#x6210;&#x4E24;&#x6B65;:<ul>
<li>1.&#x51FD;&#x6570;&#x7684;&#x5B9A;&#x4E49;</li>
<li>2.&#x51FD;&#x6570;&#x7684;&#x8C03;&#x7528;</li>
</ul>
</li>
<li>&#x6CE8;&#x610F;:&#x51FD;&#x6570;&#x7684;&#x58F0;&#x660E;&#x53EF;&#x4EE5;&#x63D0;&#x524D;&#x5230;&#x4EE3;&#x7801;&#x7684;&#x6700;&#x4E0A;&#x9762;,&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6211;&#x53EF;&#x4EE5;&#x5728;&#x51FD;&#x6570;&#x58F0;&#x660E;&#x8BED;&#x53E5;&#x524D;&#x9762;&#x4F7F;&#x7528;&#x51FD;&#x6570;,&#x540C;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x63D0;&#x524D;&#x4E00;&#x81F4;;</li>
<li>&#x5C40;&#x90E8;&#x53D8;&#x91CF;: &#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x58F0;&#x660E;&#x7684;&#x53D8;&#x91CF;&#x5728;&#x51FD;&#x6570;&#x5916;&#x9762;&#x65F6;&#x8BBF;&#x95EE;&#x4E0D;&#x5230;&#x7684;,&#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684;&#x53D8;&#x91CF;&#x79F0;&#x4E3A;&#x5C40;&#x90E8;&#x53D8;&#x91CF;;</li>
<li><p>&#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;: &#x56E0;&#x4E3A;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x7684;&#x4F5C;&#x7528;&#x53EA;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;,&#x6211;&#x4EEC;&#x79F0;&#x4E3A;&#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;;</p>
<blockquote>
<p>&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x63D0;&#x524D;,&#x610F;&#x601D;&#x5C31;&#x662F;&#x4F1A;&#x628A;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x53E5;&#x63D0;&#x5347;&#x5230;&#x6240;&#x5728;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x6700;&#x9876;&#x7AEF;&#x6765;&#x6267;&#x884C;,&#x4F46;&#x662F;&#x771F;&#x6B63;&#x7684;&#x8D4B;&#x503C;&#x8FD8;&#x662F;&#x65E9;&#x5F53;&#x524D;&#x884C;(hang);</p>
<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> aa=<span class="hljs-number">120</span>;
      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test</span>(<span class="hljs-params"></span>)</span>{
          <span class="hljs-built_in">console</span>.log(aa);<span class="hljs-comment">//undefined;</span>
          <span class="hljs-keyword">var</span> aa=<span class="hljs-number">110</span>;
          bb=<span class="hljs-number">119</span>;<span class="hljs-comment">//&#x6CA1;&#x6709;&#x901A;&#x8FC7;var &#x58F0;&#x660E;&#x7684;&#x53D8;&#x91CF;,&#x7CFB;&#x7EDF;&#x4F1A;&#x81EA;&#x52A8;&#x5C06;&#x5176;&#x8F6C;&#x5316;&#x4E3A;&#x5168;&#x5C40;&#x53D8;&#x91CF;;</span>
      }
      test();
</code></pre>
<h5 id="612-return">6.1.2 return</h5>
<p>```JavaScript
function randomNum(num){</p>
<pre><code>  var ran = Math.random();
  var res = Math.floor(ran*(num+1));
  return res;//return &#x5173;&#x952E;&#x5B57;,&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x503C; &#x4F5C;&#x4E3A;&#x51FD;&#x6570;&#x7684;&#x6700;&#x7EC8;&#x6267;&#x884C;&#x7ED3;&#x679C;;
  //return &#x540E;&#x9762;&#x7684;&#x8BED;&#x53E5;&#x662F;&#x4E0D;&#x4F1A;&#x6267;&#x884C;&#x7684;;
  console.log(&quot;&#x4E0D;&#x4F1A;&#x88AB;&#x8F93;&#x51FA;&#x7684;&quot;);
</code></pre><p>}
  var ran = randomNum(5);
  var arr= [&quot;aft&quot;,&quot;aksc&quot;,&quot;zkjsk&quot;,&quot;sgks&quot;,&quot;ahsc&quot;,&quot;asoc&quot;];
  console.log(arr[ran]);</p>
</blockquote>
<p>  function chonjiang(num){</p>
<pre><code>  var ran = randomNum(num);
  if(ran &gt; 2){
  console.log(&quot;&#x4E2D;&#x5956;&#x4E86;&quot;);            
      return;
  }
  console.log(&quot;&#x6CA1;&#x6709;&#x4E2D;&#x5956;&#xFF0C;&#x7EE7;&#x7EED;&#x5237;&#x65B0;&#x9875;&#x9762;&quot;);            
</code></pre><p>  }
  chonjiang(5);
```</p>
<h6 id="613-&#x5982;&#x4F55;&#x62FF;&#x5230;&#x51FD;&#x6570;&#x91CC;&#x9762;&#x7684;&#x53C2;&#x6570;&#x4E2A;&#x6570;">6.1.3 &#x5982;&#x4F55;&#x62FF;&#x5230;&#x51FD;&#x6570;&#x91CC;&#x9762;&#x7684;&#x53C2;&#x6570;&#x4E2A;&#x6570;</h6>
</li>
<li><p>&#x5982;&#x679C;&#x5B9E;&#x53C2;&#x4F20;&#x7684;&#x53C2;&#x6570;&#x4E2A;&#x6570;&#x5C11;&#x4E8E;&#x5F62;&#x53C2;&#x4E2A;&#x6570;,&#x90A3;&#x4E48;&#x591A;&#x51FA;&#x7684;&#x5F62;&#x53C2;&#x4F1A;&#x4EE5;undefined&#x5F62;&#x5F0F;&#x5B58;&#x5728;,&#x5982;&#x679C;&#x5B9E;&#x53C2;&#x4E2A;&#x6570;&#x591A;&#x4E8E;&#x5F62;&#x53C2;&#x4E2A;&#x6570;,&#x591A;&#x51FA;&#x7684;&#x90E8;&#x5206;&#x76F4;&#x63A5;&#x5FFD;&#x7565;;
&#x793A;&#x4F8B;:</p>
<pre><code class="lang-JavaScript">          <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-comment">//argument &#x4FDD;&#x5B58;&#x4E86;&#x7528;&#x6237;&#x8F93;&#x5165;&#x7684;&#x5B9E;&#x53C2;;</span>
              <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">arguments</span>);
              <span class="hljs-keyword">var</span> res = <span class="hljs-number">0</span>;
              <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-built_in">arguments</span>.length;i++){
                  res += <span class="hljs-built_in">arguments</span>[i];
              }
              <span class="hljs-keyword">return</span> res;
          }
          <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x6C42;&#x51FA;&#x51E0;&#x4E2A;&#x6570;&#x5B57;&#x7684;&#x548C;&quot;</span>+sum(<span class="hljs-number">1</span>,<span class="hljs-number">4</span>,<span class="hljs-number">6</span>,<span class="hljs-number">9</span>,<span class="hljs-number">11</span>,<span class="hljs-number">100</span>));

          <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getLegth</span>(<span class="hljs-params">x,y,z,n,m</span>)</span>{

          }
          <span class="hljs-built_in">console</span>.log(getLegth.length);
</code></pre>
<h4 id="62-&#x5168;&#x5C40;&#x51FD;&#x6570;">6.2 &#x5168;&#x5C40;&#x51FD;&#x6570;</h4>
</li>
<li>eval();<ul>
<li>&#x53EF;&#x4EE5;&#x628A;&#x5B57;&#x7B26;&#x4E32;&#x6839;&#x636E;&#x4E0A;&#x4E0B;&#x6587;&#x89E3;&#x6790;&#x6210;&#x4E00;&#x6BB5;&#x53EF;&#x6267;&#x884C;&#x7684;js&#x811A;&#x672C;;</li>
</ul>
</li>
<li>&#x6CE8;&#x610F;&#xFF1A;eval()&#x8981;&#x5C3D;&#x91CF;&#x5C11;&#x7528;,&quot;&#x77E5;&#x9053;&#x4ED6;,&#x5E76;&#x8FDC;&#x79BB;&#x4ED6;&quot;;
<code>console.log(eval(&quot;3+2&quot;));</code></li>
</ul>
<pre><code class="lang-JavaScript">        <span class="hljs-built_in">parseInt</span>(<span class="hljs-string">&quot;123abc&quot;</span>);<span class="hljs-comment">//123</span>
        <span class="hljs-built_in">parseInt</span>(<span class="hljs-string">&quot;a123abc&quot;</span>);<span class="hljs-comment">//NaN</span>
        <span class="hljs-built_in">parseInt</span>(<span class="hljs-string">&quot;1001&quot;</span>,<span class="hljs-number">2</span>);<span class="hljs-comment">//&#x4EE5;&#x4E8C;&#x8FDB;&#x5236;&#x6765;&#x89E3;&#x6790;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x5B57;&#x7B26;&#x4E32;,&#x6700;&#x7EC8;&#x8FD4;&#x56DE;&#x503C;&#x4ECD;&#x7136;&#x662F;&#x5341;&#x8FDB;&#x5236;;</span>
</code></pre>
<h4 id="63-&#x5B9A;&#x65F6;&#x5668;">6.3 &#x5B9A;&#x65F6;&#x5668;</h4>
<ul>
<li>1.setTimeout(function(){},time);<ul>
<li>setTimeout &#x662F;&#x53EA;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x7684;&#x5B9A;&#x65F6;&#x5668;,&#x5176;&#x4E2D;&#x533F;&#x540D;&#x51FD;&#x6570;&#x4E0D;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x624B;&#x52A8;&#x8C03;&#x7528;,&#x7CFB;&#x7EDF;&#x4F1A;&#x5728;&#x7ED9;&#x5B9A;&#x65F6;&#x95F4;&#x540E;&#x81EA;&#x52A8;&#x8C03;&#x7528;</li>
</ul>
</li>
<li>2.setInterval(function(){},time);</li>
<li>&#x8FD9;&#x4E24;&#x79CD;&#x5B9A;&#x65F6;&#x5668;&#x90FD;&#x6709;&#x8FD4;&#x56DE;&#x503C;,&#x5176;&#x503C;&#x4E3A;&#x4E00;&#x4E2A;&#x6570;&#x5B57;,&#x8868;&#x793A;&#x5F53;&#x524D;&#x5B9A;&#x65F6;&#x5668;&#x662F;&#x7B2C;&#x51E0;&#x4E2A;&#x5B9A;&#x65F6;&#x5668;;</li>
<li>clearTimeout(),clearInterval();&#x7528;&#x6765;&#x6E05;&#x9664;&#x5B9A;&#x65F6;&#x5668;;</li>
<li><p>&#x7ACB;&#x5373;&#x6267;&#x884C;&#x51FD;&#x6570; <code>(function(){})();</code></p>
<h5 id="settimeout&#x5B9A;&#x65F6;&#x5668;">setTimeout&#x5B9A;&#x65F6;&#x5668;</h5>
<p>setTimeout &#x6267;&#x884C;&#x4E00;&#x6B21;;</p>
<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> time = setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
          <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x6211;&#x4F1A;&#x5728;3000&#x6BEB;&#x79D2;&#x4EE5;&#x540E;&#x6267;&#x884C;&quot;</span>);
      },<span class="hljs-number">3000</span>)<span class="hljs-comment">//&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;time&#x7684;&#x5355;&#x4F4D;&#x662F;&#x6BEB;&#x79D2; </span>

      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">timeOut</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x6211;&#x5565;&#x5F00;&#x5976;&#x8336;&quot;</span>);
          }
          <span class="hljs-built_in">console</span>.log(timeOut);
          setTimeout(timeOut,<span class="hljs-number">3000</span>);<span class="hljs-comment">//&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x51FD;&#x6570;&#x4F53;,&#x800C;&#x4E0D;&#x662F;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;&#x7ED3;&#x679C;</span>

      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">timeOut1</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">abc</span>(<span class="hljs-params"></span>)</span>{
                  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x7231;&#x4E0A;&#x5FEB;&#x79D1;&#x6280;&#x641C;&#x6765;&#x770B;2222&quot;</span>);
              }
          }
          setTimeout(timeOut1(),<span class="hljs-number">3000</span>);
</code></pre>
<h5 id="setinterval&#x5B9A;&#x65F6;&#x5668;">setInterval&#x5B9A;&#x65F6;&#x5668;</h5>
<p>setInterval &#x4E00;&#x76F4;&#x6267;&#x884C;;</p>
<pre><code class="lang-JavaScript">          <span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;
          <span class="hljs-keyword">var</span> time2=setInterval(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-built_in">console</span>.log(i++);
              <span class="hljs-keyword">if</span>(i==<span class="hljs-number">5</span>){
                  clearInterval(time2);
              }
          },<span class="hljs-number">1000</span>)
</code></pre>
</li>
<li>setTimeout,setInterval &#x4F1A;&#x5728;&#x4E3B;&#x7A0B;&#x5E8F;&#x7684;&#x6700;&#x540E;&#x6267;&#x884C;,&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x8F93;&#x51FA;&#x4E3B;&#x7A0B;&#x5E8F;&#x7684;&#x6700;&#x540E;&#x8F93;&#x51FA;;<pre><code class="lang-JavaScript">      setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
          <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x6267;&#x884C;&#x5728;&#x524D;?&quot;</span>);
          <span class="hljs-built_in">console</span>.log(tem);
      },<span class="hljs-number">0</span>)
      <span class="hljs-keyword">var</span> tem = <span class="hljs-string">&quot;&#x4E3B;&#x6D41;&#x7A0B;&#x91CC;&#x9762;&#x7684;&#x53D8;&#x91CF;&quot;</span>;
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x5916;&#x9762;&#x7684;&#x6253;&#x5370;?&quot;</span>);
</code></pre>
</li>
</ul>
<h4 id="64-&#x83B7;&#x53D6;&#x8981;&#x64CD;&#x4F5C;&#x7684;div">6.4 &#x83B7;&#x53D6;&#x8981;&#x64CD;&#x4F5C;&#x7684;div</h4>
<pre><code class="lang-JavaScript">            <span class="hljs-keyword">var</span> div=<span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;div&quot;</span>);
            <span class="hljs-keyword">var</span> isRed= <span class="hljs-literal">false</span>;
            div.addEventListener(<span class="hljs-string">&quot;click&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">//                alert(&quot;&#x70B9;&#x6211;&#x5E72;&#x561B;&quot;)</span>
                <span class="hljs-keyword">if</span>(isRed){
                    isRed= <span class="hljs-literal">false</span>;
                    <span class="hljs-keyword">this</span>.style.background=<span class="hljs-string">&quot;skyblue&quot;</span>;
                }<span class="hljs-keyword">else</span>{
                    isRed= <span class="hljs-literal">true</span>;
                    <span class="hljs-keyword">this</span>.style.background=<span class="hljs-string">&quot;red&quot;</span>;
                }
            })
</code></pre>
<h4 id="65-&#x9012;&#x5F52;&#x51FD;&#x6570;">6.5 &#x9012;&#x5F52;&#x51FD;&#x6570;</h4>
<p>&#x9012;&#x5F52;&#x51FD;&#x6570;: &#x81EA;&#x5DF1;&#x8C03;&#x7528;&#x81EA;&#x5DF1;;<code>5!=5*4*3*2*</code></p>
<ul>
<li>&#x6CE8;&#x610F;:&#x4F7F;&#x7528;&#x9012;&#x5F52;&#x51FD;&#x6570;&#x4E00;&#x5B9A;&#x8981;&#x6CE8;&#x610F;,&#x5904;&#x7406;&#x4E0D;&#x5F53;&#x5C31;&#x4F1A;&#x8FDB;&#x5165;&#x6B7B;&#x5FAA;&#x73AF;;
&#x9636;&#x5C42;&#x6362;&#x7B97;:<pre><code class="lang-JavaScript">      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fac</span>(<span class="hljs-params">x</span>)</span>{
          <span class="hljs-keyword">if</span>(x===<span class="hljs-number">1</span>){
              <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
          }<span class="hljs-keyword">else</span>{
              <span class="hljs-keyword">return</span> x*fac(x-<span class="hljs-number">1</span>);
          }
      }
      <span class="hljs-built_in">console</span>.log(fac(<span class="hljs-number">3</span>));
</code></pre>
&#x76F8;&#x52A0;:<pre><code class="lang-JavaScript">          <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span>(<span class="hljs-params">x</span>)</span>{
              <span class="hljs-keyword">if</span>(x===<span class="hljs-number">1</span>){
                  <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
              }<span class="hljs-keyword">else</span>{
                  <span class="hljs-keyword">return</span> x+sum(x-<span class="hljs-number">1</span>);
              }
          }
          <span class="hljs-built_in">console</span>.log(sum(<span class="hljs-number">100</span>));
</code></pre>
<h4 id="66-&#x5192;&#x6CE1;&#x6392;&#x5E8F;">6.6 &#x5192;&#x6CE1;&#x6392;&#x5E8F;</h4>
<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> arr = [<span class="hljs-number">5</span>,<span class="hljs-number">1</span>,<span class="hljs-number">7</span>,<span class="hljs-number">2</span>,<span class="hljs-number">8</span>,<span class="hljs-number">10</span>,<span class="hljs-number">4</span>,<span class="hljs-number">3</span>];
      <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;i&lt;arr.length;i++){
          <span class="hljs-comment">//&#x5F53;i = 0&#x65F6;,</span>
          <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> j=i+<span class="hljs-number">1</span>;j&lt;arr.length;j++){
              <span class="hljs-comment">//&#x5F53;j = 1 &#x65F6; //arr = [1,5,7,2,8,10,4,3]</span>
              <span class="hljs-keyword">if</span>(arr[i]&gt;arr[j]){
                  <span class="hljs-keyword">var</span> tem = arr[i];
                  arr[i] = arr[j];
                  arr[j] = tem;
              }
          }
      }
      <span class="hljs-built_in">console</span>.log(arr);
</code></pre>
<h3 id="&#x7B2C;&#x4E03;&#x8282;-&#x81EA;&#x5B9A;&#x4E49;&#x5BF9;&#x8C61;">&#x7B2C;&#x4E03;&#x8282; &#x81EA;&#x5B9A;&#x4E49;&#x5BF9;&#x8C61;</h3>
<h4 id="71-&#x76F4;&#x63A5;&#x91CF;&#x6CD5;">7.1 &#x76F4;&#x63A5;&#x91CF;&#x6CD5;</h4>
</li>
<li>&#x4F18;&#x70B9;:&#x5B9E;&#x73B0;&#x8D77;&#x6765;&#x7B80;&#x5355;&#x660E;&#x4E86;;</li>
<li>&#x7F3A;&#x70B9;:&#x4E0D;&#x5BB9;&#x6613;&#x6279;&#x91CF;&#x751F;&#x4EA7;;<pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x76F4;&#x63A5;&#x91CF;&#x6CD5;</span>
      <span class="hljs-keyword">var</span> human = {
          type:<span class="hljs-string">&quot;&#x4EBA;&#x7C7B;&quot;</span>,<span class="hljs-comment">//&#x5F53;&#x524D;&#x5C5E;&#x6027;&#x7684;&#x58F0;&#x660E;&#x4F5C;&#x7528;&#x548C;&#x5728;window&#x5BF9;&#x8C61;&#x4E0B;&#x6267;&#x884C;var type = &quot;&#x4EBA;&#x7C7B;&quot;;&#x662F;&#x4E00;&#x6837;&#x7684;&#x6548;&#x679C;;</span>
          skill:<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x80FD;&#x6253;&#x80FD;&#x6297;&#x80FD;&#x8D85;&#x795E;&quot;</span>);
          }
      }
      human.skill();
      <span class="hljs-keyword">var</span> aft_girl1 = {
          name:<span class="hljs-string">&quot;fengjie&quot;</span>,
          fav:<span class="hljs-string">&quot;&#x5409;&#x8428;&#x5C31;&#x6492;&quot;</span>,
          skill:<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x5361;&#x56DB;&#x5B63;&#x82B1;&#x57CE;&quot;</span>);
          }
      }
      aft_girl1.skill();
</code></pre>
<h4 id="72-&#x5DE5;&#x5382;&#x6A21;&#x5F0F;">7.2 &#x5DE5;&#x5382;&#x6A21;&#x5F0F;</h4>
</li>
<li>&#x4F18;&#x70B9;:&#x80FD;&#x591F;&#x5B9E;&#x73B0;&#x6279;&#x91CF;&#x751F;&#x4EA7;&#x7684;&#x9700;&#x6C42;;</li>
<li>&#x7F3A;&#x70B9;:&#x770B;&#x4E0D;&#x5230;&#x751F;&#x4EA7;&#x51FA;&#x6765;&#x7684;&#x591A;&#x4E2A;&#x5BF9;&#x8C61;&#x76F4;&#x63A5;&#x7684;&#x8054;&#x7CFB;,&#x4E0D;&#x80FD;&#x53CD;&#x6620;&#x51FA;&#x5B83;&#x4EEC;&#x662F;&#x540C;&#x4E00;&#x4E2A;&#x539F;&#x578B;&#x5BF9;&#x8C61;&#x7684;&#x5B9E;&#x4F8B;<pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x5DE5;&#x5382;&#x6A21;&#x5F0F;</span>
      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pro_girl</span>(<span class="hljs-params">name,age,fav</span>)</span>{
          <span class="hljs-keyword">return</span> {
              <span class="hljs-string">&quot;name&quot;</span>:name,
              <span class="hljs-string">&quot;age&quot;</span>:age,
              <span class="hljs-string">&quot;fav&quot;</span>:fav
          }
      }
      <span class="hljs-keyword">var</span> aft_girl1 = pro_girl(<span class="hljs-string">&quot;&#x54C8;&#x513F;&#x79D1;&quot;</span>,<span class="hljs-string">&quot;18&quot;</span>,<span class="hljs-string">&quot;jsk&quot;</span>);
      <span class="hljs-built_in">console</span>.log(aft_girl1);
      <span class="hljs-keyword">var</span> aft_girl2 = pro_girl(<span class="hljs-string">&quot;dhjjs&quot;</span>,<span class="hljs-string">&quot;20&quot;</span>,<span class="hljs-string">&quot;sdjnj&quot;</span>);
      <span class="hljs-built_in">console</span>.log(aft_girl2);
</code></pre>
<h4 id="73-&#x6784;&#x9020;&#x51FD;&#x6570;&#x6A21;&#x5F0F;">7.3 &#x6784;&#x9020;&#x51FD;&#x6570;&#x6A21;&#x5F0F;</h4>
</li>
<li>&#x4F18;&#x70B9;:&#x89E3;&#x51B3;&#x4E86;&#x6279;&#x91CF;&#x751F;&#x4EA7;&#x548C;&#x591A;&#x4E2A;&#x5BF9;&#x8C61;&#x76F8;&#x5173;&#x6027;&#x67E5;&#x8BE2;&#x7684;&#x95EE;&#x9898;;</li>
<li>&#x7F3A;&#x70B9;:&#x5BF9;&#x8C61;&#x91CC;&#x9762;&#x7684;&#x65B9;&#x6CD5;&#x4F1A;&#x9020;&#x6210;&#x7A7A;&#x95F4;&#x7684;&#x6D6A;&#x8D39;;
<mark>&#x51FD;&#x6570;&#x91CC;&#x7684;this&#x6307;&#x5411;&#x95EE;&#x9898;:&#x8C01;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;,this&#x5C31;&#x6307;&#x5411;&#x8C01;;this&#x7531;&#x8C03;&#x7528;&#x65F6;&#x51B3;&#x5B9A;,&#x800C;&#x4E0D;&#x662F;&#x58F0;&#x660E;&#x65F6;;</mark><blockquote>
<p>&#x901A;&#x8FC7;new&#x5173;&#x952E;&#x5B57;&#x6765;&#x8C03;&#x7528;&#x6784;&#x9020;&#x51FD;&#x6570;,&#x4F1A;&#x9ED8;&#x8BA4;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x65B0;&#x5BF9;&#x8C61;,&#x8FD9;&#x4E2A;&#x65B0;&#x5BF9;&#x8C61;&#x5177;&#x6709;&#x6784;&#x9020;&#x51FD;&#x6570;&#x5B9A;&#x4E49;&#x7684;&#x5C5E;&#x6027;(&#x53D8;&#x91CF;)&#x548C;&#x65B9;&#x6CD5;(&#x51FD;&#x6570;);</p>
</blockquote>
</li>
</ul>
<ul>
<li>&#x7C7B;: &#x5176;&#x5B9E;&#x5C31;&#x662F;&#x6211;&#x4EEC;js&#x91CC;&#x9762;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;;</li>
<li>&#x5B9E;&#x4F8B;&#x5316;:&#x6309;&#x7167;&#x7C7B;&#x89C4;&#x5B9A;&#x597D;&#x7684;&#x6837;&#x5B50;&#x751F;&#x4EA7;&#x51FA;&#x6765;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x8FC7;&#x7A0B;&#x5C31;&#x662F;&#x5B9E;&#x4F8B;&#x5316;;<code>new</code></li>
<li><p>&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x7528;&#x6765;&#x751F;&#x4EA7;&#x5BF9;&#x8C61;&#x7684;,&#x4ED6;&#x672C;&#x8EAB;&#x5E76;&#x4E0D;&#x662F;&#x4F60;&#x60F3;&#x8981;&#x7684;&#x5BF9;&#x8C61;,&#x53EF;&#x4EE5;&#x628A;&#x4ED6;&#x7406;&#x89E3;&#x4E3A;&#x4ED6;&#x662F;&#x4F60;&#x8981;&#x751F;&#x4EA7;&#x7684;&#x4EA7;&#x54C1;&#x7684;&#x673A;&#x5668;;</p>
<pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x6784;&#x9020;&#x51FD;&#x6570;&#x6A21;&#x5F0F;</span>
      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Create_girlObj</span>(<span class="hljs-params">name,age,fav</span>)</span>{
          <span class="hljs-keyword">this</span>.name = name;
          <span class="hljs-keyword">this</span>.age = age;
          <span class="hljs-keyword">this</span>.fav = fav;
          <span class="hljs-keyword">this</span>.skill=<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
              <span class="hljs-keyword">var</span> a = <span class="hljs-string">&quot;&#x6211;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;,&#x4E5F;&#x662F;&#x53EF;&#x4EE5;&#x58F0;&#x660E;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;,&#x548C;&#x5176;&#x4ED6;&#x4EBA;&#x6CA1;&#x5173;&#x7CFB;&quot;</span>;    
              <span class="hljs-comment">//&#x5728;&#x65B9;&#x6CD5;&#x5185;&#x90E8;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x901A;&#x8FC7;this&#x62FF;&#x5230;&#x5916;&#x9762;&#x5C5E;&#x6027;;</span>
              <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.name+<span class="hljs-string">&quot;&#x963F;&#x82CF;&#x5FEB;&#x56DE;&#x5BB6;&quot;</span>);
          };
      }
      <span class="hljs-keyword">var</span> aft_girl1 = <span class="hljs-keyword">new</span> Create_girlObj(<span class="hljs-string">&quot;fensj&quot;</span>,<span class="hljs-number">18</span>,<span class="hljs-string">&quot;&#x597D;&#x51E0;&#x5341;&quot;</span>);<span class="hljs-comment">//&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x5316;</span>
      <span class="hljs-keyword">var</span> aft_girl2 = <span class="hljs-keyword">new</span> Create_girlObj(<span class="hljs-string">&quot;fensj&quot;</span>,<span class="hljs-number">18</span>,<span class="hljs-string">&quot;&#x597D;&#x51E0;&#x5341;&quot;</span>);
      <span class="hljs-built_in">console</span>.log(aft_girl1.name);
      <span class="hljs-built_in">console</span>.log(aft_girl1 == aft_girl2);<span class="hljs-comment">//false;</span>
      <span class="hljs-comment">//&#x5728;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6A21;&#x5F0F;&#x4E2D;,&#x5B9E;&#x4F8B;&#x5316;&#x51FA;&#x6765;&#x7684;&#x5BF9;&#x8C61;aft_girl1&#x548C;aft_girl2&#x4F1A;&#x81EA;&#x52A8;&#x542B;&#x6709;&#x4E00;&#x4E2A;constructor&#x5C5E;&#x6027;,&#x6307;&#x5411;&#x4ED6;&#x4EEC;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;;</span>
      <span class="hljs-built_in">console</span>.log(aft_girl1.constructor );<span class="hljs-comment">//&#x62FF;&#x5230;&#x751F;&#x4EA7;&#x673A;&#x5668;</span>
      <span class="hljs-built_in">console</span>.log(aft_girl1.constructor == aft_girl2.constructor);<span class="hljs-comment">//&#x8FD4;&#x56DE;true,&#x8BF4;&#x660E;&#x8FD9;&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x662F;&#x540C;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x751F;&#x6210;&#x7684;;</span>
      <span class="hljs-comment">//JavaScript&#x8FD8;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;instanceof&#x8FD0;&#x7B97;&#x7B26;,&#x9A8C;&#x8BC1;&#x539F;&#x578B;&#x5BF9;&#x8C61;&#x4E0E;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;;</span>
      <span class="hljs-built_in">console</span>.log(aft_girl1 <span class="hljs-keyword">instanceof</span> Create_girlObj    );<span class="hljs-comment">//true</span>

      aft_girl1.skill();

      <span class="hljs-built_in">console</span>.log(aft_girl1.skill);
      <span class="hljs-built_in">console</span>.log(aft_girl2.skill);
      <span class="hljs-built_in">console</span>.log(aft_girl1.skill == aft_girl2.skill);
</code></pre>
<h4 id="74-&#x539F;&#x578B;&#x6A21;&#x5F0F;">7.4 &#x539F;&#x578B;&#x6A21;&#x5F0F;</h4>
</li>
<li>&#x4F18;&#x70B9;:&#x89E3;&#x51B3;&#x4E86;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6A21;&#x5F0F;&#x7684;&#x7A7A;&#x95F4;&#x6D6A;&#x8D39;&#x95EE;&#x9898;</li>
<li><p>&#x7F3A;&#x70B9;:&#x4E0D;&#x5BB9;&#x6613;&#x6279;&#x91CF;&#x751F;&#x4EA7;;</p>
<blockquote>
<p>JavaScript&#x89C4;&#x5B9A;,&#x6BCF;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x90FD;&#x6709;&#x4E00;&#x4E2A;prototype&#x5C5E;&#x6027;,&#x6307;&#x5411;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;,&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;,&#x90FD;&#x4F1A;&#x88AB;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x4F8B;&#x7EE7;&#x627F;;</p>
</blockquote>
</li>
<li><p>&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x6784;&#x9020;&#x51FD;&#x6570;&#x751F;&#x4EA7;&#x7684;&#x5BF9;&#x8C61;&#x7EE7;&#x627F;&#x4E86;&#x4E0A;&#x8FF0;&#x7684;&#x7B2C;&#x4E09;&#x8005;&#x7684;&#x6240;&#x6709;&#x65B9;&#x6CD5;&#x4EE5;&#x53CA;&#x5C5E;&#x6027;;</p>
<ul>
<li>&#x7EE7;&#x627F;&#x5C31;&#x662F;&#x7238;&#x7238;&#x6709;&#x7684;&#x624B;&#x827A;,&#x5982;&#x679C;&#x513F;&#x5B50;&#x7EE7;&#x627F;&#x4E86;&#x7238;&#x7238;,&#x90A3;&#x4E48;&#x513F;&#x5B50;&#x4E5F;&#x4F1A;&#x8FD9;&#x95E8;&#x624B;&#x827A;<pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x539F;&#x578B;&#x6A21;&#x5F0F;</span>
  <span class="hljs-built_in">console</span>.log(Create_girlObj.prototype);<span class="hljs-comment">//&#x6307;&#x5411;&#x4E86;&#x4E00;&#x4E2A;&#x7B2C;&#x4E09;&#x8005;&#x5BF9;&#x8C61;</span>
  <span class="hljs-built_in">console</span>.log(Create_girlObj.prototype.constructor == aft_girl1.constructor);<span class="hljs-comment">//true </span>
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">CreatGirl</span>(<span class="hljs-params"></span>)</span>{};<span class="hljs-comment">//&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;</span>
  CreatGirl.prototype.name = <span class="hljs-string">&quot;sjsci&quot;</span>;
  CreatGirl.prototype.age = <span class="hljs-number">18</span>;
  CreatGirl.prototype.fav = <span class="hljs-string">&quot;&#x56DB;&#x6D77;&#x6167;&#x5BFA;&quot;</span>;
  CreatGirl.prototype.skill = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
      <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.name+<span class="hljs-string">&quot;&#x4F3A;&#x670D;&#x7535;&#x673A;&#x6765;&#x770B;&quot;</span>);
  };
  <span class="hljs-keyword">var</span> aft_girl3 = <span class="hljs-keyword">new</span> CreatGirl();
  <span class="hljs-keyword">var</span> aft_girl4 = <span class="hljs-keyword">new</span> CreatGirl();
  <span class="hljs-built_in">console</span>.log(aft_girl3);
  aft_girl3.skill();
  <span class="hljs-built_in">console</span>.log(aft_girl3.skill === aft_girl4.skill);<span class="hljs-comment">//true</span>
</code></pre>
<h4 id="75-&#x6DF7;&#x5408;&#x6A21;&#x5F0F;">7.5 &#x6DF7;&#x5408;&#x6A21;&#x5F0F;</h4>
</li>
</ul>
</li>
<li>&#x628A;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x5B9A;&#x4E49;&#x653E;&#x5728;&#x6784;&#x9020;&#x51FD;&#x6570;&#x91CC;&#x9762;,&#x628A;&#x6240;&#x6709;&#x65B9;&#x6CD5;&#x5B9A;&#x4E49;&#x653E;&#x5728;prototype&#x539F;&#x578B;&#x91CC;&#x9762;;</li>
<li><p><strong>proto</strong>&#x4E0E;prototype</p>
<ul>
<li>prototype &#x53EA;&#x5B58;&#x5728;&#x4E8E;&#x6784;&#x9020;&#x51FD;&#x6570; (&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;)</li>
<li><strong>proto</strong>&#x53EA;&#x5B58;&#x5728;&#x4E8E;&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x6784;&#x9020;&#x51FD;&#x6570;&#x751F;&#x6210;&#x7684;&#x5BF9;&#x8C61; (&#x751F;&#x6210;&#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;)</li>
<li><p>&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;&#x7684;<strong>proto</strong>&#x6307;&#x5411;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;prototype</p>
<pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x7EC8;&#x6781;&#x89E3;&#x51B3;&#x65B9;&#x6848;:&#x6DF7;&#x5408;&#x6A21;&#x5F0F;</span>
      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">CreatGG</span>(<span class="hljs-params">name,age,fav</span>)</span>{
          <span class="hljs-keyword">this</span>.name = name;
          <span class="hljs-keyword">this</span>.age = age;
          <span class="hljs-keyword">this</span>.fav = fav;
      }
      CreatGG.prototype.skill = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
          <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.name + <span class="hljs-string">&quot;&#x5982;&#x679C;&#x4EE5;&#x54E6;&quot;</span>);
      }
      <span class="hljs-keyword">var</span> aft_girl1 = <span class="hljs-keyword">new</span> CreatGG(<span class="hljs-string">&quot;ushiu&quot;</span>,<span class="hljs-number">18</span>,<span class="hljs-string">&quot;&#x5965;&#x8FEA;&quot;</span>);
      <span class="hljs-keyword">var</span> aft_girl2 = <span class="hljs-keyword">new</span> CreatGG(<span class="hljs-string">&quot;hthguih&quot;</span>,<span class="hljs-number">20</span>,<span class="hljs-string">&quot;&#x4E00;&quot;</span>);
      aft_girl2.skill();
      <span class="hljs-built_in">console</span>.log(aft_girl1.skill === aft_girl2.skill);

      <span class="hljs-built_in">console</span>.log(aft_girl1.__proto__ === CreatGG.prototype);<span class="hljs-comment">//true</span>
</code></pre>
<h4 id="76-es6">7.6 ES6</h4>
<pre><code class="lang-JavaScript">  <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Ani</span></span>{
      constructor(){
          <span class="hljs-keyword">this</span>.species = <span class="hljs-string">&quot;&#x52A8;&#x7269;&quot;</span>;
      }
  }
  <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Cat</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Ani</span></span>{
      constructor(type,gender){
          <span class="hljs-keyword">super</span>();
          <span class="hljs-keyword">this</span>.type = type;
          <span class="hljs-keyword">this</span>.gender = gender;
      }
      skill(){
          <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${this.type}</span>&#x7C7B;&#x578B;&#x7684;&#x732B;,&#x6293;&#x8001;&#x9F20;&#x4E00;&#x6D41;`</span>)
      }
      fav(){
          <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${this.type}</span>&#x7C7B;&#x578B;&#x7684;&#x732B;,&#x6700;&#x7231;&#x5E72;&#x51C0;`</span>)
      }
  }
  <span class="hljs-keyword">var</span> bsm = <span class="hljs-keyword">new</span> Cat(<span class="hljs-string">&quot;&#x6CE2;&#x65AF;&#x732B;&quot;</span>,<span class="hljs-string">&quot;femal&quot;</span>);
  <span class="hljs-built_in">console</span>.log(bsm);
  bsm.skill();
</code></pre>
<h3 id="&#x7B2C;&#x516B;&#x8282;-&#x7CFB;&#x7EDF;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;">&#x7B2C;&#x516B;&#x8282; &#x7CFB;&#x7EDF;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;</h3>
<h4 id="81-&#x65F6;&#x95F4;-date">8.1 &#x65F6;&#x95F4; Date</h4>
<blockquote>
<p>&#x6700;&#x521D;&#x7684;&#x65F6;&#x95F4;&#x6233; &#x4E3A;1970.01.01 8:00</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<h5 id="811-&#x5B9A;&#x4E49;&#x65F6;&#x95F4;">8.1.1 &#x5B9A;&#x4E49;&#x65F6;&#x95F4;:</h5>
<ul>
<li>&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> date1 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;;</span>
<span class="hljs-built_in">console</span>.log(date1);
</code></pre>
</li>
<li>&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x5F0F;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> date2 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">10000000000000</span>);<span class="hljs-comment">//&#x63A5;&#x6536;&#x4E00;&#x4E2A;&#x6BEB;&#x79D2;&#x6570;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;;</span>
<span class="hljs-built_in">console</span>.log(date2);
</code></pre>
</li>
<li>&#x7B2C;&#x4E09;&#x79CD;&#x65B9;&#x5F0F;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> date3 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-string">&quot;2017-10-20 8:00&quot;</span>);<span class="hljs-comment">//&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x65E5;&#x671F;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-built_in">console</span>.log(date3);
</code></pre>
</li>
<li>&#x7B2C;&#x56DB;&#x79CD;&#x65B9;&#x5F0F;            <pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> date4 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2017</span>,<span class="hljs-number">10</span>,<span class="hljs-number">25</span>,<span class="hljs-number">12</span>,<span class="hljs-number">20</span>,<span class="hljs-number">30</span>,<span class="hljs-number">500</span>);<span class="hljs-comment">//&#x5206;&#x522B;&#x4F20;&#x5165;&#x65F6;&#x95F4;&#x6570;&#x636E;,&#x8FD9;&#x91CC;&#x6CE8;&#x610F;&#x6708;&#x4EFD;&#x662F;&#x4ECE;0&#x5F00;&#x59CB;&#x7684;;</span>
<span class="hljs-built_in">console</span>.log(date4);
</code></pre>
<h5 id="812-get">8.1.2 get</h5>
get &#x83B7;&#x53D6;&#x65F6;&#x95F4;&#x503C;&#x7684;&#x65B9;&#x6CD5;<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(date1.getFullYear());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5E74;;</span>
<span class="hljs-built_in">console</span>.log(date1.getMonth());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x6708;,&#x4ECE;0&#x5F00;&#x59CB;;</span>
<span class="hljs-built_in">console</span>.log(date1.getDate());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x65E5;&#x671F;;</span>
<span class="hljs-built_in">console</span>.log(date1.getDay());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x661F;&#x671F;;</span>
<span class="hljs-built_in">console</span>.log(date1.getHours());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5C0F;&#x65F6;</span>
<span class="hljs-built_in">console</span>.log(date1.getMinutes());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5206;&#x949F;</span>
<span class="hljs-built_in">console</span>.log(date1.getSeconds());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x79D2;</span>
<span class="hljs-built_in">console</span>.log(date1.getMilliseconds());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x6BEB;&#x79D2;</span>
<span class="hljs-built_in">console</span>.log(date1.getTime());<span class="hljs-comment">//&#x83B7;&#x53D6;&#x65E5;&#x671F;&#x5BF9;&#x8C61;&#x5230;1970.01.01 8:00</span>
</code></pre>
<h5 id="813-set">8.1.3 set</h5>
set &#x4FEE;&#x6539;&#x65F6;&#x95F4;&#x7684;&#x503C;<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(date1.setFullYear(<span class="hljs-number">2018</span>));<span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x65E5;&#x671F;&#x5BF9;&#x8C61;&#x7684;&#x5E74;&#x6570;,&#x8FD4;&#x56DE;&#x503C;&#x4E3A;&#x65B0;&#x65E5;&#x671F;&#x5230;1970.01.01&#x7684;&#x6BEB;&#x79D2;&#x6570;</span>
<span class="hljs-built_in">console</span>.log(date1.getFullYear());
date1.setMonth(<span class="hljs-number">10</span>);
date1.setDate(<span class="hljs-number">25</span>);
date1.setHours(<span class="hljs-number">12</span>);
date1.setMinutes(<span class="hljs-number">30</span>);
date1.setSeconds(<span class="hljs-number">20</span>);
<span class="hljs-built_in">console</span>.log(date1);
</code></pre>
<h5 id="814-tolocalestring">8.1.4 toLocaleString</h5>
&#x6839;&#x636E;&#x672C;&#x5730;&#x65F6;&#x95F4;&#x628A; Date &#x5BF9;&#x8C61;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#xFF1A;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> d=<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();
<span class="hljs-keyword">var</span> n=d.toLocaleString();
n &#x8F93;&#x51FA;&#x7ED3;&#x679C;:
<span class="hljs-number">2017</span>/<span class="hljs-number">10</span>/<span class="hljs-number">21</span> &#x4E0B;&#x5348;<span class="hljs-number">3</span>:<span class="hljs-number">40</span>:<span class="hljs-number">39</span>
</code></pre>
</li>
</ul>
<h4 id="82-math-&#x6570;&#x5B66;&#x5BF9;&#x8C61;">8.2 Math &#x6570;&#x5B66;&#x5BF9;&#x8C61;</h4>
<p><mark>Math &#x6570;&#x5B66;&#x5BF9;&#x8C61;&#x4E0D;&#x9700;&#x8981;new,&#x800C;&#x662F;&#x76F4;&#x63A5;&#x4F7F;&#x7528;</mark></p>
<ul>
<li>&#x3C0;&#x7684;&#x503C; <code>console.log(Math.PI);</code></li>
<li>&#x53D6;&#x6574; <code>console.log(Math.abs(-5));</code></li>
<li>&#x5411;&#x4E0A;&#x53D6;&#x6574;,&#x5927;&#x4E8E;&#x5F53;&#x524D;&#x6570;&#x5B57;&#x7684;&#x6700;&#x5C0F;&#x6574;&#x6570;<code>console.log(Math.ceil(2.011));//&#x8FD4;&#x56DE;3</code></li>
<li>&#x5411;&#x4E0B;&#x53D6;&#x6574;<code>console.log(Math.floor(3.9));</code></li>
<li>&#x56DB;&#x820D;&#x4E94;&#x5165;<code>console.log(Math.round(3.5));</code></li>
<li>&#x8BA1;&#x7B97;&#x5F27;&#x5EA6;&#x7684;&#x503C;<pre><code class="lang-JavaScript">  <span class="hljs-comment">//30deg =&gt; pi/6 xdeg =&gt; x/180*pi</span>
  <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Math</span>.sin(<span class="hljs-built_in">Math</span>.PI/<span class="hljs-number">6</span>));<span class="hljs-comment">//Math.sin&#x63A5;&#x6536;&#x7684;&#x53C2;&#x6570;&#x4E3A;&#x5F27;&#x5EA6;</span>
</code></pre>
</li>
<li>&#x6C42;&#x5E42;<code>console.log(Math.pow(3,2));// &#x65B9;&#x6CD5;&#x8FD4;&#x56DE; x &#x7684; y &#x6B21;&#x5E42;</code></li>
<li>&#x968F;&#x673A;&#x6570; <pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random()*<span class="hljs-number">6</span>+<span class="hljs-number">5</span>));<span class="hljs-comment">//5-10&#x4E4B;&#x95F4;&#x7684;&#x968F;&#x673A;&#x6B63;&#x6574;&#x6570;</span>
<span class="hljs-comment">//&#x83B7;&#x53D6;&#x521D;&#x59CB;&#x503C;&#x5230;&#x672B;&#x5C3E;&#x503C;&#x4E4B;&#x95F4;&#x7684;&#x968F;&#x673A;&#x6574;&#x6570;,&#x4E0D;&#x5305;&#x62EC;&#x672B;&#x5C3E;&#x503C;</span>
<span class="hljs-comment">//Math.floor(Math.random()*(&#x672B;&#x5C3E;&#x503C;-&#x521D;&#x59CB;&#x503C;)+&#x521D;&#x59CB;&#x503C;);</span>
</code></pre>
</li>
</ul>
<h4 id="83-&#x5B57;&#x7B26;&#x4E32;-string">8.3 &#x5B57;&#x7B26;&#x4E32; String</h4>
<h5 id="831-&#x521B;&#x5EFA;">8.3.1 &#x521B;&#x5EFA;</h5>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> str1 = <span class="hljs-string">&quot;ejjf&#x4E16;&#x754C;f&#x7684;f&#x7236;&#x7EA7;&quot;</span>;
<span class="hljs-keyword">var</span> str2 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">String</span>(<span class="hljs-string">&quot;&#x59D0;&#x798F;&#x65BD;&#x798F;&#x62C5;&#x60CA;&#x53D7;&#x6050;&quot;</span>);
<span class="hljs-built_in">console</span>.log(str1);
<span class="hljs-built_in">console</span>.log(str1.length);<span class="hljs-comment">//length&#x5C5E;&#x6027;</span>
<span class="hljs-built_in">console</span>.log(str2);
</code></pre>
<h5 id="832&#x65B9;&#x6CD5;">8.3.2&#x65B9;&#x6CD5;</h5>
<ul>
<li><code>charAt();</code>&#x83B7;&#x53D6;&#x6307;&#x5B9A;&#x4E0B;&#x6807;&#x503C;&#x7684;&#x503C;,&#x8FD4;&#x56DE;&#x5728;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x7684;&#x5B57;&#x7B26;</li>
<li><code>concat();</code>&#x5B57;&#x7B26;&#x4E32;&#x62FC;&#x63A5;,&#x8FDE;&#x63A5;&#x4E24;&#x4E2A;&#x6216;&#x66F4;&#x591A;&#x5B57;&#x7B26;&#x4E32;,&#x8FD4;&#x56DE;&#x65B0;&#x5B57;&#x7B26;&#x4E32;</li>
<li><code>indexOf();</code>&#x8FD4;&#x56DE;&#x67D0;&#x4E2A;&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x503C;&#x5728;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x9996;&#x6B21;&#x51FA;&#x73B0;&#x7684;&#x4F4D;&#x7F6E;&#x3002;</li>
<li><code>match()</code> &#x67E5;&#x627E;&#x627E;&#x5230;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;,&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;</li>
<li><code>replace()</code>&#x5728;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x67E5;&#x627E;&#x5339;&#x914D;&#x7684;&#x5B50;&#x4E32;&#xFF0C; &#x5E76;&#x66FF;&#x6362;&#x4E0E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x7684;&#x5B50;&#x4E32;,&#x8FD4;&#x56DE;&#x66FF;&#x6362;&#x540E;&#x65B0;&#x5B57;&#x7B26;&#x4E32;,&#x53EA;&#x66FF;&#x6362;&#x7B2C;&#x4E00;&#x4E2A;</li>
<li><code>substr()</code>&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x8868;&#x793A;&#x622A;&#x53D6;&#x7684;&#x8D77;&#x59CB;&#x4F4D;&#x7F6E;,&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x8868;&#x793A;&#x8981;&#x622A;&#x53D6;&#x7684;&#x957F;&#x5EA6;;    &#x4ECE;&#x8D77;&#x59CB;&#x7D22;&#x5F15;&#x53F7;&#x63D0;&#x53D6;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x6307;&#x5B9A;&#x6570;&#x76EE;&#x7684;&#x5B57;&#x7B26;&#x3002;</li>
<li><code>substring()</code>&#x63D0;&#x53D6;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x4E24;&#x4E2A;&#x6307;&#x5B9A;&#x7684;&#x7D22;&#x5F15;&#x53F7;&#x4E4B;&#x95F4;&#x7684;&#x5B57;&#x7B26;;&#x63A5;&#x6536;&#x53C2;&#x6570;&#x4F4D;&#x8D77;&#x59CB;&#x548C;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;,&#x4E0D;&#x53EF;&#x4EE5;&#x4E3A;&#x8D1F;&#x6570; </li>
<li><code>split()</code>    &#x628A;&#x5B57;&#x7B26;&#x4E32;&#x5206;&#x5272;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#x6570;&#x7EC4;</li>
<li><code>trim()</code> &#x53BB;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x4E24;&#x8FB9;&#x7684;&#x7A7A;&#x683C;</li>
<li><p><code>toUpperCase()</code>&#x8F6C;&#x5316;&#x4E3A;&#x5927;&#x5199;,&#x4E0D;&#x6539;&#x53D8;&#x539F;&#x5B57;&#x7B26;&#x4E32;</p>
<pre><code class="lang-JavaScript">
          <span class="hljs-comment">//&#x7EC3;&#x4E60;  &#x5C06;&quot;&#x5927;&#x5BB6;&quot;&#x66FF;&#x6362;&#x6210;&quot;&#x4F60;&#x4EEC;&quot;</span>
          <span class="hljs-keyword">var</span> str8 = <span class="hljs-string">&quot;&#x5728;&#x4E00;&#x4E2A;&#x591A;&#x5C0F;&#x65F6;&#x7684;&#x65F6;&#x95F4;&#x5185;&#xFF0C;&#x4E94;&#x4F4D;&#x4EE3;&#x8868;&#x975E;&#x5E38;&#x5766;&#x8BDA;&#x5730;&#x56DE;&#x5E94;&#x4E86;&#x4E2D;&#x5916;&#x5A92;&#x4F53;&#x5341;&#x591A;&#x4E2A;&#x95EE;&#x9898;&#x3002;&#x521A;&#x624D;&#x6211;&#x4EEC;&#x5728;&#x4F11;&#x606F;&#x5BA4;&#x91CC;&#x804A;&#x5929;&#xFF0C;&#x5927;&#x5BB6;&#x6628;&#x5929;&#x90FD;&#x5728;&#x73B0;&#x573A;&#x8046;&#x542C;&#x603B;&#x4E66;&#x8BB0;&#x7684;&#x62A5;&#x544A;&#xFF0C;&#x7279;&#x522B;&#x662F;&#x8C08;&#x5230;&#x603B;&#x4E66;&#x8BB0;&#x5F3A;&#x8C03;&#x575A;&#x6301;&#x5168;&#x9762;&#x4F9D;&#x6CD5;&#x6CBB;&#x56FD;&#xFF0C;&#x5927;&#x5BB6;&#x90FD;&#x5206;&#x4EAB;&#x4E86;&#x4ED6;&#x4EEC;&#x5404;&#x81EA;&#x7684;&#x5FC3;&#x58F0;&#x3002;&#x6211;&#x60F3;&#xFF0C;&#x4ECA;&#x5929;&#x4E94;&#x4F4D;&#x4EE3;&#x8868;&#x5BF9;&#x73B0;&#x573A;&#x63D0;&#x95EE;&#x7684;&#x56DE;&#x7B54;&#xFF0C;&#x4E5F;&#x662F;&#x6211;&#x4EEC;&#x653F;&#x6CD5;&#x7CFB;&#x7EDF;&#x7684;&#x4EE3;&#x8868;&#xFF0C;&#x901A;&#x8FC7;&#x81EA;&#x8EAB;&#x7684;&#x611F;&#x53D7;&#x3001;&#x81EA;&#x5DF1;&#x7684;&#x5DE5;&#x4F5C;&#x6765;&#x5BF9;&#x5B66;&#x4E60;&#x9886;&#x4F1A;&#x603B;&#x4E66;&#x8BB0;&#x62A5;&#x544A;&#x7684;&#x6700;&#x597D;&#x547C;&#x5E94;&#xFF0C;&#x4E5F;&#x662F;&#x5BF9;&#x5A92;&#x4F53;&#x670B;&#x53CB;&#x4EEC;&#x5305;&#x62EC;&#x767E;&#x59D3;&#x5173;&#x5207;&#x7684;&#x6700;&#x597D;&#x56DE;&#x5E94;&#x3002;&#x5E0C;&#x671B;&#x5A92;&#x4F53;&#x670B;&#x53CB;&#x4EEC;&#x7EE7;&#x7EED;&#x5173;&#x6CE8;&#x653F;&#x6CD5;&#x7CFB;&#x7EDF;&#x7684;&#x5DE5;&#x4F5C;&#xFF0C;&#x7ED9;&#x4E88;&#x6211;&#x4EEC;&#x66F4;&#x591A;&#x7684;&#x652F;&#x6301;&#x3002;&#x4ECA;&#x5929;&#x7684;&#x96C6;&#x4F53;&#x91C7;&#x8BBF;&#x5230;&#x6B64;&#x7ED3;&#x675F;&#xFF0C;&#x518D;&#x6B21;&#x611F;&#x8C22;&#x4E94;&#x4F4D;&#x4EE3;&#x8868;&#xFF0C;&#x4E5F;&#x8C22;&#x8C22;&#x5927;&#x5BB6;&#x3002;&quot;</span>
<span class="hljs-comment">//            console.log(str8.replace(/\&#x5927;&#x5BB6;/g,&quot;&#x4F60;&#x4EEC;&quot;));</span>
          <span class="hljs-keyword">while</span>(str8.indexOf(<span class="hljs-string">&quot;&#x5927;&#x5BB6;&quot;</span>)!= -<span class="hljs-number">1</span>){
              str8 = str8.replace(<span class="hljs-string">&quot;&#x5927;&#x5BB6;&quot;</span>,<span class="hljs-string">&quot;&#x4F60;&#x4EEC;&quot;</span>);
          }
          <span class="hljs-built_in">document</span>.body.innerHTML = str8;
          <span class="hljs-comment">//&#x7EDF;&#x8BA1;&quot;&#x5927;&#x5BB6;&quot;&#x51FA;&#x73B0;&#x7684;&#x6B21;&#x6570;</span>
          <span class="hljs-keyword">var</span> str9 = <span class="hljs-string">&quot;&#x5728;&#x4E00;&#x4E2A;&#x591A;&#x5C0F;&#x65F6;&#x7684;&#x65F6;&#x95F4;&#x5185;&#xFF0C;&#x4E94;&#x4F4D;&#x4EE3;&#x8868;&#x975E;&#x5E38;&#x5766;&#x8BDA;&#x5730;&#x56DE;&#x5E94;&#x4E86;&#x4E2D;&#x5916;&#x5A92;&#x4F53;&#x5341;&#x591A;&#x4E2A;&#x95EE;&#x9898;&#x3002;&#x521A;&#x624D;&#x6211;&#x4EEC;&#x5728;&#x4F11;&#x606F;&#x5BA4;&#x91CC;&#x804A;&#x5929;&#xFF0C;&#x5927;&#x5BB6;&#x6628;&#x5929;&#x90FD;&#x5728;&#x73B0;&#x573A;&#x8046;&#x542C;&#x603B;&#x4E66;&#x8BB0;&#x7684;&#x62A5;&#x544A;&#xFF0C;&#x7279;&#x522B;&#x662F;&#x8C08;&#x5230;&#x603B;&#x4E66;&#x8BB0;&#x5F3A;&#x8C03;&#x575A;&#x6301;&#x5168;&#x9762;&#x4F9D;&#x6CD5;&#x6CBB;&#x56FD;&#xFF0C;&#x5927;&#x5BB6;&#x90FD;&#x5206;&#x4EAB;&#x4E86;&#x4ED6;&#x4EEC;&#x5404;&#x81EA;&#x7684;&#x5FC3;&#x58F0;&#x3002;&#x6211;&#x60F3;&#xFF0C;&#x4ECA;&#x5929;&#x4E94;&#x4F4D;&#x4EE3;&#x8868;&#x5BF9;&#x73B0;&#x573A;&#x63D0;&#x95EE;&#x7684;&#x56DE;&#x7B54;&#xFF0C;&#x4E5F;&#x662F;&#x6211;&#x4EEC;&#x653F;&#x6CD5;&#x7CFB;&#x7EDF;&#x7684;&#x4EE3;&#x8868;&#xFF0C;&#x5927;&#x5BB6;&#x901A;&#x8FC7;&#x81EA;&#x8EAB;&#x7684;&#x611F;&#x53D7;&#x3001;&#x81EA;&#x5DF1;&#x7684;&#x5DE5;&#x4F5C;&#x6765;&#x5BF9;&#x5B66;&#x4E60;&#x9886;&#x4F1A;&#x603B;&#x4E66;&#x8BB0;&#x62A5;&#x544A;&#x7684;&#x6700;&#x597D;&#x547C;&#x5E94;&#xFF0C;&#x4E5F;&#x662F;&#x5BF9;&#x5A92;&#x4F53;&#x670B;&#x53CB;&#x4EEC;&#x5305;&#x62EC;&#x767E;&#x59D3;&#x5173;&#x5207;&#x7684;&#x6700;&#x597D;&#x56DE;&#x5E94;&#x3002;&#x5E0C;&#x671B;&#x5A92;&#x4F53;&#x670B;&#x53CB;&#x4EEC;&#x7EE7;&#x7EED;&#x5173;&#x6CE8;&#x653F;&#x6CD5;&#x7CFB;&#x7EDF;&#x7684;&#x5DE5;&#x4F5C;&#xFF0C;&#x5927;&#x5BB6;&#x7ED9;&#x4E88;&#x6211;&#x4EEC;&#x66F4;&#x591A;&#x7684;&#x652F;&#x6301;&#x3002;&#x4ECA;&#x5929;&#x7684;&#x96C6;&#x4F53;&#x91C7;&#x8BBF;&#x5230;&#x6B64;&#x7ED3;&#x675F;&#xFF0C;&#x518D;&#x6B21;&#x611F;&#x8C22;&#x4E94;&#x4F4D;&#x4EE3;&#x8868;&#xFF0C;&#x4E5F;&#x8C22;&#x8C22;&#x5927;&#x5BB6;&#x3002;&quot;</span>
          <span class="hljs-keyword">var</span> index = <span class="hljs-number">0</span>;
          <span class="hljs-keyword">var</span> count = <span class="hljs-number">0</span>;
          <span class="hljs-keyword">var</span> target = <span class="hljs-string">&quot;&#x5927;&#x5BB6;&quot;</span>;
          <span class="hljs-keyword">while</span>(str9.indexOf(target,index)!=-<span class="hljs-number">1</span>){
              count++;
              index = str9.indexOf(<span class="hljs-string">&quot;&#x5927;&#x5BB6;&quot;</span>,index)+target.length;
          }
          alert(count);
</code></pre>
<h4 id="84-array-&#x6570;&#x7EC4;">8.4 Array &#x6570;&#x7EC4;</h4>
<h5 id="841-&#x65B0;&#x5EFA;&#x6570;&#x7EC4;">8.4.1 &#x65B0;&#x5EFA;&#x6570;&#x7EC4;</h5>
</li>
<li>&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;<code>var arr1 = [&quot;12&quot;];</code></li>
<li>&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x7A7A;&#x6570;&#x7EC4;<code>var arr2 = new Array();</code></li>
<li><code>var arr3 = new Array(&quot;12&quot;);</code><h5 id="842-&#x65B9;&#x6CD5;">8.4.2 &#x65B9;&#x6CD5;</h5>
</li>
<li>&#x89C4;&#x5B9A;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5C0F;&#x957F;&#x5EA6;<code>var arr4 = new Array(2);</code></li>
<li>&#x8FD4;&#x56DE;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;<code>console.log(arr4.length);</code></li>
<li>&#x5728;&#x6570;&#x7EC4;&#x672B;&#x5C3E;&#x8FFD;&#x52A0;&#x4E00;&#x4E2A;&#x5143;&#x7D20;<code>arr1.push(&quot;2&quot;);</code></li>
<li>&#x5728;&#x6570;&#x7EC4;&#x524D;&#x9762;&#x589E;&#x52A0;&#x4E00;&#x4E2A;&#x5143;&#x7D20;<code>arr1.unshift(&quot;ax&quot;);</code></li>
<li>&#x5220;&#x9664;&#x672B;&#x5C3E;&#x5143;&#x7D20;,&#x8FD4;&#x56DE;&#x503C;&#x4E3A;&#x88AB;&#x5220;&#x9664;&#x5143;&#x7D20;<code>var tem = arr1.pop();</code></li>
<li>&#x5220;&#x9664;&#x6570;&#x7EC4;&#x5934;&#x90E8;&#x5143;&#x7D20;<code>var tem2 =  arr1.shift();</code></li>
<li>&#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x7684;&#x5220;&#x9664;&#x548C;&#x6DFB;&#x52A0;  splice();<ul>
<li>&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x5220;&#x9664;&#x6216;&#x8005;&#x589E;&#x52A0;&#x7684;&#x4F4D;&#x7F6E;;(&#x5FC5;&#x586B;)</li>
<li>&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x8868;&#x793A;&#x8981;&#x5220;&#x9664;&#x7684;&#x4E2A;&#x6570;;(&#x5FC5;&#x586B;)</li>
<li>&#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#x4EE5;&#x540E;&#x7684;&#x53C2;&#x6570;&#x4E3A;&#x65B0;&#x589E;&#x7684;&#x5143;&#x7D20;(&#x9009;&#x586B;)</li>
<li>&#x8FD4;&#x56DE;&#x503C;&#x4E3A;&#x5220;&#x9664;&#x5143;&#x7D20;&#x7EC4;&#x6210;&#x7684;&#x6570;&#x7EC4;</li>
</ul>
</li>
<li>&#x6570;&#x7EC4;&#x7684;&#x62FC;&#x63A5;,&#x4E0D;&#x66F4;&#x6539;&#x539F;&#x6570;&#x7EC4;,&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x62FC;&#x63A5;&#x540E;&#x7684;&#x65B0;&#x6570;&#x7EC4;<code>concat();</code></li>
<li>&#x4ECE;&#x6570;&#x7EC4;&#x7684;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x62F7;&#x8D1D;&#x5143;&#x7D20;&#x5230;&#x6570;&#x7EC4;&#x7684;&#x53E6;&#x4E00;&#x4E2A;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x4E2D;&#x3002;<code>copyWithin()</code>
&#x793A;&#x4F8B;:<pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x590D;&#x5236;&#x6570;&#x7EC4;&#x7684;&#x524D;&#x9762;&#x4E24;&#x4E2A;&#x5143;&#x7D20;&#x5230;&#x540E;&#x9762;&#x4E24;&#x4E2A;&#x5143;&#x7D20;&#x4E0A;&#xFF1A;</span>
<span class="hljs-keyword">var</span> fruits = [<span class="hljs-string">&quot;Banana&quot;</span>, <span class="hljs-string">&quot;Orange&quot;</span>, <span class="hljs-string">&quot;Apple&quot;</span>, <span class="hljs-string">&quot;Mango&quot;</span>];
fruits.copyWithin(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>);
<span class="hljs-comment">//&#x7ED3;&#x679C;&#x4E3A;:Banana,Orange,Banana,Orange</span>
</code></pre>
</li>
<li><code>filter()</code>&#x68C0;&#x6D4B;&#x6570;&#x503C;&#x5143;&#x7D20;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x6240;&#x6709;&#x5143;&#x7D20;&#x7684;&#x6570;&#x7EC4;&#x3002;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> arr6 = [<span class="hljs-number">12</span>,<span class="hljs-number">10</span>,<span class="hljs-number">15</span>,<span class="hljs-number">65</span>,<span class="hljs-number">56</span>,<span class="hljs-number">17</span>,<span class="hljs-number">9</span>];
          <span class="hljs-comment">//&#x6570;&#x7EC4;&#x91CC;&#x9762;&#x7684;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x90FD;&#x4F1A;&#x6267;&#x884C;&#x4E00;&#x6B21;filter&#x91CC;&#x9762;&#x7684;&#x8FC7;&#x6EE4;&#x51FD;&#x6570;,&#x5982;&#x679C;&#x51FD;&#x6570;&#x6267;&#x884C;&#x7ED3;&#x679C;return&#x51FA;&#x6765;&#x4E00;&#x4E2A;true,&#x5219;&#x8BA4;&#x4E3A;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7B26;&#x5408;&#x8981;&#x6C42;,&#x5426;&#x5219;&#x4E0D;&#x7B26;&#x5408;&#x8981;&#x6C42;</span>
          <span class="hljs-keyword">var</span> res = arr6.filter(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">curVal,index</span>)</span>{
              <span class="hljs-built_in">console</span>.log(index);
<span class="hljs-comment">//                if(curVal &gt; 10){ </span>
<span class="hljs-comment">//                    return true;</span>
<span class="hljs-comment">//                }</span>
              <span class="hljs-keyword">if</span>(index%<span class="hljs-number">2</span>==<span class="hljs-number">1</span>){
                  <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
              }
          })
          <span class="hljs-built_in">console</span>.log(res);
</code></pre>
</li>
<li><code>find</code>&#x7684;&#x7528;&#x6CD5;&#x548C;<code>filter</code>&#x4E00;&#x6837;,&#x4F46;&#x662F;&#x5F53;&#x6709;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x6EE1;&#x8DB3;&#x8981;&#x6C42;&#x65F6;,&#x5C31;&#x4E0D;&#x4F1A;&#x518D;&#x7EE7;&#x7EED;&#x5224;&#x65AD;&#x5269;&#x4F59;&#x5143;&#x7D20;</li>
<li><code>forEach()</code>&#x6570;&#x7EC4;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x90FD;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x56DE;&#x8C03;&#x51FD;&#x6570;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> divs = <span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">&quot;div&quot;</span>);
      divs.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">curVal,index</span>)</span>{<span class="hljs-comment">//&#x6570;&#x7EC4;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x90FD;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x3002;</span>
          curVal.style.fontSize = <span class="hljs-string">&quot;25px&quot;</span>;
          <span class="hljs-keyword">if</span>(index%<span class="hljs-number">2</span>==<span class="hljs-number">0</span>){
              curVal.style.color = <span class="hljs-string">&quot;red&quot;</span>;
          }
      })
</code></pre>
</li>
<li><code>indexOf</code>&#x641C;&#x7D22;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;&#x5B83;&#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#x3002;<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(arr1);
      <span class="hljs-built_in">console</span>.log(arr1.indexOf(<span class="hljs-string">&quot;bibi&quot;</span>));<span class="hljs-comment">//&#x8FD4;&#x56DE;&#x7B2C;&#x4E00;&#x4E2A;&#x641C;&#x7D22;&#x7ED3;&#x679C;&#x7684;&#x4E0B;&#x6807;&#x51C6;,&#x5BF9;&#x6BD4;lastIndexOf()&#x8FD4;&#x56DE;&#x6700;&#x540E;&#x4E00;&#x4F4D;</span>
      <span class="hljs-built_in">console</span>.log(arr1.indexOf(<span class="hljs-string">&quot;bibi0&quot;</span>));<span class="hljs-comment">//&#x641C;&#x7D22;&#x4E0D;&#x5230;&#x7ED3;&#x679C;&#x8FD4;&#x56DE;-1</span>
      <span class="hljs-built_in">console</span>.log(arr1.indexOf(<span class="hljs-string">&quot;bibi&quot;</span>,<span class="hljs-number">3</span>));<span class="hljs-comment">//&#x6307;&#x5B9A;&#x5F00;&#x59CB;&#x641C;&#x7D22;&#x4F4D;&#x7F6E;</span>
</code></pre>
</li>
<li><code>join</code> &#x628A;&#x6570;&#x7EC4;&#x8F6C;&#x6362;&#x6210;&#x5B57;&#x7B26;&#x4E32;<code>console.log(arr2.join(&quot;-&quot;));</code></li>
<li><code>reverse()</code> &#x53CD;&#x8F6C;&#x6570;&#x7EC4;&#x7684;&#x5143;&#x7D20;&#x987A;&#x5E8F;</li>
<li>sort() &#x5BF9;&#x6570;&#x7EC4;&#x7684;&#x5143;&#x7D20;&#x8FDB;&#x884C;&#x6392;&#x5E8F;,&#x4FEE;&#x6539;&#x539F;&#x6570;&#x7EC4;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> arr6 = [<span class="hljs-number">12</span>,<span class="hljs-number">10</span>,<span class="hljs-number">15</span>,<span class="hljs-number">65</span>,<span class="hljs-number">56</span>,<span class="hljs-number">17</span>,<span class="hljs-number">9</span>];
  <span class="hljs-built_in">console</span>.log(arr6);
  <span class="hljs-built_in">console</span>.log(arr6.sort(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">a,b</span>)</span>{
      <span class="hljs-keyword">return</span> a-b
      <span class="hljs-comment">//return &#x4E00;&#x4E2A;&#x6B63;&#x503C;,&#x7CFB;&#x7EDF;&#x4F1A;&#x8BA4;&#x4E3A;a&#x5927;&#x4E8E;b;</span>
      <span class="hljs-comment">//return 0 &#x8BA4;&#x4E3A;a=b;</span>
      <span class="hljs-comment">//return &#x4E00;&#x4E2A;&#x8D1F;&#x503C;,&#x8BA4;&#x4E3A;a&#x5C0F;&#x4E8E;b;</span>
  }));
  <span class="hljs-built_in">console</span>.log(arr6);
</code></pre>
</li>
<li><p>every &#x548C; some &#x8FD4;&#x56DE;&#x5E03;&#x5C14;&#x503C;</p>
<ul>
<li>every &#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x90FD;&#x7B26;&#x5408;&#x8981;&#x6C42;(&#x51FD;&#x6570;&#x90FD;&#x8FD4;&#x56DE;true),&#x624D;&#x80FD;&#x8FD4;&#x56DE;true;<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(arr6.every(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">curVal,index</span>)</span>{
  <span class="hljs-keyword">return</span> curVal&gt;<span class="hljs-number">10</span>;
}))
</code></pre>
</li>
<li>some &#x6570;&#x7EC4;&#x7684;&#x5176;&#x4E2D;&#x6709;&#x5143;&#x7D20;&#x7B26;&#x5408;&#x8981;&#x6C42;&#x5373;&#x53EF;&#x8FD4;&#x56DE;true;<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(arr6.some(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">curVal,index</span>)</span>{
  <span class="hljs-keyword">return</span> curVal&gt;<span class="hljs-number">10</span>;
}))
</code></pre>
</li>
</ul>
</li>
<li><p>map &#x6570;&#x7EC4;&#x7684;&#x6620;&#x5C04;,&#x6839;&#x636E;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#x751F;&#x6210;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(arr6);
<span class="hljs-keyword">var</span> arr7 = arr6.map(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">curVal,index</span>)</span>{
  <span class="hljs-keyword">return</span> curVal*<span class="hljs-number">2</span>
})
<span class="hljs-built_in">console</span>.log(arr7);
</code></pre>
</li>
</ul>
<h3 id="&#x7B2C;&#x4E5D;&#x8282;-bom-and-dom">&#x7B2C;&#x4E5D;&#x8282; BOM and DOM</h3>
<h4 id="91-bom">9.1 BOM</h4>
<p>BOM &#x6D4F;&#x89C8;&#x5668;&#x5BF9;&#x8C61;&#x6A21;&#x578B;(Browser Object Model)</p>
<ul>
<li>&#x66B4;&#x9732; &#x4E86;&#x4E00;&#x4E9B;&#x63A5;&#x53E3;,&#x8BA9;&#x6211;&#x4EEC;&#x5177;&#x6709;&#x64CD;&#x4F5C;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x80FD;&#x529B;</li>
<li>js&#x91CC;&#x9762;&#x6700;&#x5927;&#x5BF9;&#x8C61;&#x5C31;&#x662F;window,&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x7528;&#x7684;&#x5168;&#x5C40;&#x51FD;&#x6570;&#x793A;&#x4F8B;,&#x5982;alert(),setTimeout(),setInterval()&#x7B49;&#x7B49;&#x90FD;&#x662F;window&#x4E0B;&#x7684;&#x65B9;&#x6CD5;</li>
<li><code>window.innerHeight</code> &#x8FD4;&#x56DE;&#x7A97;&#x53E3;&#x7684;&#x6587;&#x6863;&#x663E;&#x793A;&#x533A;&#x7684;&#x9AD8;&#x5EA6;,&#x4E0D;&#x5305;&#x62EC;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x83DC;&#x5355;&#x680F;,&#x72B6;&#x6001;&#x680F;,&#x4EE5;&#x53CA;&#x6EDA;&#x52A8;&#x6761;&#x7B49;;&#x6CE8;&#x610F;:&#x8FD4;&#x56DE;&#x503C;&#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;,&#x6CA1;&#x6709;&#x5355;&#x4F4D;
<code>console.log(window.innerHeight);//&#x8FD4;&#x56DE;&#x7A97;&#x53E3;&#x7684;&#x6587;&#x6863;&#x663E;&#x793A;&#x533A;&#x7684;&#x9AD8;&#x5EA6;&#x3002;</code></li>
<li>window.outerHeight &#x8FD4;&#x56DE;&#x7684;&#x662F;&#x8FD9;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x9AD8;&#x5EA6;,&#x5305;&#x62EC;&#x83DC;&#x5355;&#x680F;&#x7B49;
<code>console.log(window.outerHeight);//&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x8FD9;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x9AD8;&#x5EA6;&#x3002;</code></li>
<li><code>close());</code>&#x5173;&#x95ED;&#x9875;&#x9762;</li>
<li><code>window.open(&quot;http://www.baidu.com&quot;);</code>&#x6253;&#x5F00;&#x65B0;&#x7A97;&#x53E3;<h5 id="912-location&#x5BF9;&#x8C61;">9.1.2 location&#x5BF9;&#x8C61;</h5>
location&#x5BF9;&#x8C61; &#x4E3B;&#x8981;&#x5305;&#x62EC;&#x4E86;&#x5730;&#x5740;&#x680F;SUL&#x7684;&#x76F8;&#x5173;&#x4FE1;&#x606F;
<code>console.log(location.href);</code>    &#x8FD4;&#x56DE;&#x5B8C;&#x6574;&#x7684;URL<pre><code class="lang-JavaScript">      <span class="hljs-keyword">var</span> but = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;button&quot;</span>);
      but.addEventListener(<span class="hljs-string">&quot;click&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
          <span class="hljs-comment">//location.href = &quot;http://www.baidu.com&quot;;//&#x91CD;&#x70B9;,&#x8FD4;&#x56DE;&#x5B8C;&#x6574;&#x7684;URL</span>
          <span class="hljs-built_in">console</span>.log(location.hash);<span class="hljs-comment">//&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;URL&#x7684;&#x951A;&#x90E8;&#x5206;</span>
          <span class="hljs-built_in">console</span>.log(location.port);<span class="hljs-comment">//&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;URL&#x670D;&#x52A1;&#x5668;&#x4F7F;&#x7528;&#x7684;&#x7AEF;&#x53E3;&#x53F7;</span>
          <span class="hljs-built_in">console</span>.log(location.host);<span class="hljs-comment">//&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;URL&#x7684;&#x4E3B;&#x673A;&#x540D;&#x548C;&#x7AEF;&#x53E3;</span>
          location.reload();<span class="hljs-comment">//&#x5C0F;&#x91CD;&#x70B9;  ,&#x91CD;&#x65B0;&#x8F7D;&#x5165;&#x5F53;&#x524D;&#x6587;&#x6863;</span>
      })
</code></pre>
<h5 id="913-history">9.1.3 history</h5>
</li>
<li>back();&#x52A0;&#x8F7D; history &#x5217;&#x8868;&#x4E2D;&#x7684;&#x524D;&#x4E00;&#x4E2A; URL</li>
<li>forward();&#x52A0;&#x8F7D; history &#x5217;&#x8868;&#x4E2D;&#x7684;&#x4E0B;&#x4E00;&#x4E2A; URL</li>
<li><p>go();&#x52A0;&#x8F7D; history &#x5217;&#x8868;&#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x5177;&#x4F53;&#x9875;&#x9762;</p>
<pre><code class="lang-HTML">      &#x8FD9;&#x662F;&#x7B2C;&#x4E00;&#x4E2A;&#x9875;&#x9762;
      <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;test2.html&quot;</span>&gt;</span>&#x8DF3;&#x8F6C;&#x5230;&#x7B2C;&#x4E8C;&#x4E2A;&#x9875;&#x9762;<span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-title">button</span>&gt;</span>&#x524D;&#x8FDB;<span class="hljs-tag">&lt;/<span class="hljs-title">button</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-title">button</span>&gt;</span>&#x540E;&#x9000;<span class="hljs-tag">&lt;/<span class="hljs-title">button</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-title">script</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text/javascript&quot;</span>&gt;</span><span class="javascript">
          <span class="hljs-comment">//history</span>
          <span class="hljs-keyword">var</span> but = <span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">&quot;button&quot;</span>);
          but[<span class="hljs-number">0</span>].addEventListener(<span class="hljs-string">&quot;click&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
              history.back();
          })
          but[<span class="hljs-number">1</span>].addEventListener(<span class="hljs-string">&quot;click&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
              history.back();
          })

      </span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
</code></pre>
<h5 id="914-screen">9.1.4 screen</h5>
</li>
<li>screen.width/height &#x8FD4;&#x56DE;&#x5C4F;&#x5E55;&#x7684;&#x603B;&#x5BBD;&#x9AD8;</li>
<li>screen.availWidth/availHeight &#x8FD4;&#x56DE;&#x5C4F;&#x5E55;&#x53EF;&#x7528;&#x5BBD;&#x9AD8;,&#x5373;&#x4E0D;&#x5305;&#x62EC;&#x7CFB;&#x7EDF;&#x7684;&#x4EFB;&#x52A1;&#x680F;</li>
<li>colorDepth    &#x8FD4;&#x56DE;&#x76EE;&#x6807;&#x8BBE;&#x5907;&#x6216;&#x7F13;&#x51B2;&#x5668;&#x4E0A;&#x7684;&#x8C03;&#x8272;&#x677F;&#x7684;&#x6BD4;&#x7279;&#x6DF1;&#x5EA6;</li>
<li>pixelDepth    &#x8FD4;&#x56DE;&#x5C4F;&#x5E55;&#x7684;&#x989C;&#x8272;&#x5206;&#x8FA8;&#x7387;&#xFF08;&#x6BCF;&#x8C61;&#x7D20;&#x7684;&#x4F4D;&#x6570;&#xFF09;<pre><code class="lang-JavaScript"><span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">window</span>.screen.width);
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">window</span>.screen.height);
<span class="hljs-built_in">console</span>.log(screen.availWidth);
<span class="hljs-built_in">console</span>.log(screen.availHeight);
</code></pre>
<h5 id="915-navigator">9.1.5 Navigator</h5>
</li>
<li><code>appCodeName</code>    &#x8FD4;&#x56DE;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x4EE3;&#x7801;&#x540D;</li>
<li><code>appName</code>    &#x8FD4;&#x56DE;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x540D;&#x79F0;</li>
<li><code>appVersion</code>    &#x8FD4;&#x56DE;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x5E73;&#x53F0;&#x548C;&#x7248;&#x672C;&#x4FE1;&#x606F;</li>
<li><code>cookieEnabled</code>    &#x8FD4;&#x56DE;&#x6307;&#x660E;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x662F;&#x5426;&#x542F;&#x7528; cookie &#x7684;&#x5E03;&#x5C14;&#x503C;</li>
<li><code>platform</code>    &#x8FD4;&#x56DE;&#x8FD0;&#x884C;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x5E73;&#x53F0;</li>
<li><code>userAgent</code>    &#x8FD4;&#x56DE;&#x7531;&#x5BA2;&#x6237;&#x673A;&#x53D1;&#x9001;&#x670D;&#x52A1;&#x5668;&#x7684;user-agent &#x5934;&#x90E8;&#x7684;&#x503C;</li>
</ul>
<h4 id="92-dom">9.2 DOM</h4>
<p>DOM &#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B;(Document Object Model)</p>
<ul>
<li>&#x63D0;&#x4F9B;&#x4E00;&#x4E9B;&#x63A5;&#x53E3;,&#x8BA9;&#x6211;&#x4EEC;&#x5177;&#x6709;&#x64CD;&#x4F5C;HTML&#x7ED3;&#x6784;&#x80FD;&#x529B;</li>
<li>&#x8282;&#x70B9;:<ul>
<li>&#x5143;&#x7D20;&#x8282;&#x70B9;(&#x8282;&#x70B9;&#x7C7B;&#x578B;&#x4E3A; 1 );</li>
<li>&#x6587;&#x672C;&#x8282;&#x70B9;</li>
<li>&#x5C5E;&#x6027;&#x8282;&#x70B9;<pre><code class="lang-JavaScript"><span class="hljs-built_in">document</span>.write(<span class="hljs-string">&quot;&#x5411;&#x6587;&#x6863;&#x91CC;&#x9762;&#x5199;&#x4E1C;&#x897F;&quot;</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">document</span>.body);<span class="hljs-comment">//&#x8FD4;&#x56DE;&#x6587;&#x6863;&#x7684;body&#x5BF9;&#x8C61;</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">document</span>.body.nodeType);<span class="hljs-comment">//&#x8FD4;&#x56DE;1</span>
</code></pre>
</li>
</ul>
</li>
</ul>
<h5 id="922-&#x5982;&#x4F55;&#x9009;&#x5230;html&#x5143;&#x7D20;">9.2.2 &#x5982;&#x4F55;&#x9009;&#x5230;HTML&#x5143;&#x7D20;</h5>
<ul>
<li>document.querySelector()
<code>document.querySelector(&quot;div&quot;) &#x63A5;&#x6536;&#x7684;&#x53C2;&#x6570;&#x4E3A;&#x4E00;&#x4E2A;CSS3&#x9009;&#x62E9;&#x5668;</code>&#x5982;&#x679C;&#x4F20;&#x8FDB;&#x53BB;&#x7684;CSS3&#x9009;&#x62E9;&#x5668;&#x53EF;&#x7528;&#x9009;&#x4E2D;&#x591A;&#x4E2A;&#x5143;&#x7D20;,&#x90A3;&#x4E48;&#x53EA;&#x8FD4;&#x56DE;&#x7B2C;&#x4E00;&#x4E2A;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> div = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;div&quot;</span>);<span class="hljs-comment">//CSS3&#x9009;&#x62E9;&#x5668;</span>
div.style.color = <span class="hljs-string">&quot;red&quot;</span>;
<span class="hljs-built_in">console</span>.log(div);
</code></pre>
</li>
<li>document.querySelectorAll()&#x7528;&#x6CD5;&#x540C;querySelector,&#x4F46;&#x4ED6;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7C7B;&#x6570;&#x7EC4;,&#x5C31;&#x7B97;CSS3&#x9009;&#x62E9;&#x5668;&#x53EA;&#x80FD;&#x9009;&#x4E2D;&#x4E00;&#x4E2A;,&#x4ED6;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x4ECD;&#x7136;&#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#x6570;&#x7EC4;,&#x53EA;&#x4E0D;&#x8FC7;&#x8FD9;&#x4E2A;&#x6570;&#x7EC4;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x5143;&#x7D20;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> divs = <span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">&quot;div&quot;</span>);
<span class="hljs-built_in">console</span>.log(divs);
divs[<span class="hljs-number">1</span>].style.background = <span class="hljs-string">&quot;yellow&quot;</span>;
</code></pre>
</li>
<li>getElementById() &#x53C2;&#x6570;&#x4E3A;id&#x540D;,&#x4E0D;&#x9700;&#x8981;&#x52A0;#;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> one = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">&quot;one&quot;</span>);<span class="hljs-comment">//id&#x540D;,&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7C7B;&#x6570;&#x7EC4;</span>
<span class="hljs-built_in">console</span>.log(one);
</code></pre>
</li>
<li>getElementsByTagName() &#x53C2;&#x6570;&#x4E3A;&#x6807;&#x7B7E;&#x540D;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> divs2 = <span class="hljs-built_in">document</span>.getElementsByTagName(<span class="hljs-string">&quot;div&quot;</span>);<span class="hljs-comment">//&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7C7B;&#x6570;&#x7EC4;</span>
<span class="hljs-built_in">console</span>.log(divs2);
</code></pre>
</li>
<li>getElementsByClassName() &#x53C2;&#x6570;&#x4E3A;&#x7C7B;&#x540D;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> div2 = <span class="hljs-built_in">document</span>.getElementsByClassName(<span class="hljs-string">&quot;two&quot;</span>);<span class="hljs-comment">//&#x83B7;&#x53D6;&#x7C7B;&#x540D;,&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7C7B;&#x6570;&#x7EC4;</span>
<span class="hljs-built_in">console</span>.log(div2);
</code></pre>
</li>
<li>&#x90FD;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7C7B;&#x6570;&#x7EC4;;</li>
</ul>
<h5 id="923-&#x5982;&#x4F55;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;html&#x7ED3;&#x6784;&#x5E76;&#x4E14;&#x63D2;&#x5165;&#x5230;html&#x91CC;&#x9762;">9.2.3 &#x5982;&#x4F55;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;HTML&#x7ED3;&#x6784;&#x5E76;&#x4E14;&#x63D2;&#x5165;&#x5230;HTML&#x91CC;&#x9762;</h5>
<ul>
<li><code>createElement()</code>&#x751F;&#x6210;&#x7684;&#x5143;&#x7D20;&#x5B58;&#x5728;&#x4E8E;&#x5185;&#x5B58;&#x4E2D;,&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;DOM&#x5143;&#x7D20;&#x8282;&#x70B9;
<code>var myDiv = document.createElement(&quot;div&quot;);//&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</code></li>
<li>element.appendChild(child)&#x628A;child&#x8FD9;&#x4E2A;&#x5B50;&#x8282;&#x70B9;&#x8FFD;&#x52A0;&#x5230;baba&#x8FD9;&#x4E2A;&#x8282;&#x70B9;&#x91CC;&#x9762;&#x7684;&#x672B;&#x5C3E;
<code>one.appendChild(myDiv);//&#x63D2;&#x5165;&#x5230;id&#x4E3A;one&#x7684;div&#x91CC;&#x9762;</code>             </li>
<li><code>this.remove();</code>  &#x5220;&#x9664;</li>
<li>&#x64CD;&#x4F5C;&#x6587;&#x672C;&#x8282;&#x70B9;    innerHTML,innerText&#x8FD9;&#x4E24;&#x4E2A;&#x5C5E;&#x6027;&#x5171;&#x540C;&#x70B9;&#x90FD;&#x662F;&#x5411;&#x5143;&#x7D20;&#x8282;&#x70B9;&#x5185;&#x63D2;&#x5165;&#x6587;&#x672C;,&#x4F46;&#x662F;&#x524D;&#x8005;&#x8BC6;&#x522B;html&#x6807;&#x7B7E;,&#x540E;&#x8005;&#x4E0D;&#x8BC6;&#x522B;;&#x8FD9;&#x4E24;&#x4E2A;&#x5C5E;&#x6027;&#x662F;&#x53EF;&#x8BFB;&#x53EF;&#x5199;&#x7684;!<pre><code class="lang-JavaScript">  myDiv.innerText = <span class="hljs-string">&quot;&lt;b&gt;&#x6211;&#x662F;&#x901A;&#x8FC7;innerText&#x63D2;&#x5165;&#x8FDB;&#x6765;&#x7684;&lt;/b&gt;&quot;</span>;
  myDiv.innerHTML += <span class="hljs-string">&quot;&lt;b&gt;&#x6211;&#x662F;&#x8FFD;&#x52A0;&#x8FDB;&#x6765;&#x7684;&lt;/b&gt;&quot;</span>;
  <span class="hljs-comment">//&#x53EF;&#x8BFB;</span>
  <span class="hljs-keyword">var</span> str = myDiv.innerText;<span class="hljs-comment">//&#x4E0D;&#x8BC6;&#x522B;&#x6807;&#x7B7E;</span>
  <span class="hljs-keyword">var</span> str2 = myDiv.innerHTML;<span class="hljs-comment">//&#x8BC6;&#x522B;&#x6807;&#x7B7E;</span>
</code></pre>
</li>
<li>element.setAttribute(); &#x8BBE;&#x7F6E;&#x6216;&#x8005;&#x6539;&#x53D8;&#x6307;&#x5B9A;&#x5C5E;&#x6027;&#x5E76;&#x6307;&#x5B9A;&#x503C;&#x3002;    <pre><code class="lang-JavaScript"><span class="hljs-comment">//&#x56FE;&#x7247;&#x5207;&#x6362;</span>
<span class="hljs-keyword">var</span> but = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;button&quot;</span>);
but.addEventListener(<span class="hljs-string">&quot;click&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-keyword">var</span> img = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;img&quot;</span>);
  img.setAttribute(<span class="hljs-string">&quot;src&quot;</span>,<span class="hljs-string">&quot;img/lufei.jpg&quot;</span>);
  img.style=<span class="hljs-string">&quot;transform:scale(.8)&quot;</span>;
  <span class="hljs-built_in">console</span>.log(img.getAttribute(<span class="hljs-string">&quot;alt&quot;</span>));
})
</code></pre>
</li>
</ul>
<h3 id="&#x7B2C;&#x5341;&#x8282;-&#x64CD;&#x7EB5;dom">&#x7B2C;&#x5341;&#x8282; &#x64CD;&#x7EB5;DOM</h3>
<h4 id="101-class">10.1 class</h4>
<ul>
<li>element.className &#x64CD;&#x4F5C;&#x7C7B;&#x540D;,&#x53EF;&#x8BFB;&#x53EF;&#x5199; <code>webDiv.className +=&quot; test&quot;;</code></li>
<li>element.classList.add &#x6DFB;&#x52A0;&#x7C7B;&#x540D;<code>webDiv.classList.add(&quot;test2&quot;);</code></li>
<li>element.classList.remove &#x79FB;&#x9664;&#x7C7B;&#x540D; <code>this.classList.remove(&quot;test2&quot;);</code></li>
<li>element.classList.toggle() &#x5207;&#x6362;&#x7C7B;&#x540D; <code>this.classList.toggle(&quot;test2&quot;);</code><h4 id="102-client">10.2 client</h4>
</li>
<li>element.clientWidth &#x5728;&#x9875;&#x9762;&#x4E0A;&#x8FD4;&#x56DE;&#x5185;&#x5BB9;&#x7684;&#x53EF;&#x89C6;&#x5BBD;&#x5EA6;&#xFF08;&#x4E0D;&#x5305;&#x62EC;&#x8FB9;&#x6846;&#xFF0C;&#x8FB9;&#x8DDD;&#x6216;&#x6EDA;&#x52A8;&#x6761;&#xFF09;</li>
<li>element.clientHeight &#x5728;&#x9875;&#x9762;&#x4E0A;&#x8FD4;&#x56DE;&#x5185;&#x5BB9;&#x7684;&#x53EF;&#x89C6;&#x9AD8;&#x5EA6;&#xFF08;&#x4E0D;&#x5305;&#x62EC;&#x8FB9;&#x6846;&#xFF0C;&#x8FB9;&#x8DDD;&#x6216;&#x6EDA;&#x52A8;&#x6761;&#xFF09;</li>
<li>element.offsetWidth &#x8FD4;&#x56DE;&#x5143;&#x7D20;&#x7684;&#x5BBD;&#x5EA6;&#xFF0C;&#x5305;&#x62EC;&#x8FB9;&#x6846;&#x548C;&#x586B;&#x5145;&#xFF0C;&#x4F46;&#x4E0D;&#x662F;&#x8FB9;&#x8DDD;</li>
<li>element.offsetHeight &#x8FD4;&#x56DE;&#xFF0C;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x9AD8;&#x5EA6;&#x5305;&#x62EC;&#x8FB9;&#x6846;&#x548C;&#x586B;&#x5145;&#xFF0C;&#x4F46;&#x4E0D;&#x662F;&#x8FB9;&#x8DDD;<blockquote>
<p>offsetWidth/offsetHeight&#x5305;&#x62EC;&#x4E86;div&#x8FB9;&#x6846;,&#x800C;clientWidth/clientHeight&#x4E0D;&#x5305;&#x62EC;&#x8FB9;&#x6846;</p>
</blockquote>
</li>
</ul>
<ul>
<li>element. &#x5982;&#x679C;&#x4EE3;&#x7801;&#x6709;&#x6362;&#x884C;,&#x8FD4;&#x56DE;&#x4E86;&#x4E00;&#x4E2A;&#x6587;&#x672C;&#x8282;&#x70B9;,&#x56E0;&#x4E3A;&#x6362;&#x884C;&#x4F1A;&#x8F93;&#x51FA;&#x4E00;&#x4E2A;&#x7A7A;&#x683C;</li>
<li>element.childNodes &#x8FD4;&#x56DE;&#x6240;&#x6709;&#x7684;&#x5B50;&#x8282;&#x70B9;,&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;</li>
<li>element.focus(); &#x8BA9;input&#x6846;&#x81EA;&#x52A8;&#x83B7;&#x53D6;&#x7126;&#x70B9;</li>
<li>element.insertBefore &#x9996;&#x5148;&#x662F;&#x5B9E;&#x73B0;&#x5411;&#x5143;&#x7D20;&#x91CC;&#x9762;&#x6DFB;&#x52A0;&#x5B50;&#x8282;&#x70B9;,&#x65B9;&#x6CD5;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x8981;&#x6DFB;&#x52A0;&#x7684;&#x5B50;&#x8282;&#x70B9;,&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x6307;&#x5B9A;&#x4E86;&#x65B0;&#x8282;&#x70B9;&#x6DFB;&#x52A0;&#x7684;&#x4F4D;&#x7F6E;(&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x8282;&#x70B9;&#x524D;&#x9762;)</li>
<li>element.nodeName &#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5927;&#x5199;&#x7684;&#x6807;&#x7B7E;&#x540D;</li>
<li>element.removeChild(); &#x79FB;&#x9664;&#x5B50;&#x8282;&#x70B9; </li>
<li>element.offsetLeft    &#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7684;&#x76F8;&#x5BF9;&#x6C34;&#x5E73;&#x504F;&#x79FB;&#x4F4D;&#x7F6E;&#x7684;&#x504F;&#x79FB;&#x5BB9;&#x5668;</li>
<li>element.offsetParent    &#x8FD4;&#x56DE;&#x5143;&#x7D20;&#x7684;&#x504F;&#x79FB;&#x5BB9;&#x5668;</li>
<li>element.offsetTop    &#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7684;&#x76F8;&#x5BF9;&#x5782;&#x76F4;&#x504F;&#x79FB;&#x4F4D;&#x7F6E;&#x7684;&#x504F;&#x79FB;&#x5BB9;&#x5668;</li>
</ul>
<h3 id="&#x7B2C;&#x5341;&#x4E00;&#x8282;-event">&#x7B2C;&#x5341;&#x4E00;&#x8282; event</h3>
<h4 id="111-&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;">11.1 &#x70B9;&#x51FB;&#x4E8B;&#x4EF6;</h4>
<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;click&quot;</span>,abc)
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">abc</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;&quot;</span>);
}
</code></pre>
<h4 id="112-&#x9F20;&#x6807;&#x4E8B;&#x4EF6;">11.2 &#x9F20;&#x6807;&#x4E8B;&#x4EF6;</h4>
<ul>
<li>&#x89E6;&#x53D1;&#x65F6;&#x95F4;  mousedown -&gt; mouseup -&gt; click</li>
<li>mousedown &#x9F20;&#x6807;&#x6309;&#x94AE;&#x88AB;&#x6309;&#x4E0B;<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;mousedown&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x9F20;&#x6807;&#x6309;&#x4E0B;&quot;</span>);
})
</code></pre>
</li>
<li>mouseup &#x9F20;&#x6807;&#x6309;&#x952E;&#x88AB;&#x677E;&#x5F00;<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;mouseup&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x9F20;&#x6807;&#x677E;&#x5F00;&quot;</span>);
})
</code></pre>
</li>
<li>mouseover &#x9F20;&#x6807;&#x79FB;&#x5230;&#x67D0;&#x5143;&#x7D20;&#x4E4B;&#x4E0A;&#x3002;<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;mouseover&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x9F20;&#x6807;&#x8FDB;&#x5165;mouseover&quot;</span>);
  <span class="hljs-keyword">this</span>.style.transform = <span class="hljs-string">&quot;scale(1.2)&quot;</span>;
})
</code></pre>
</li>
<li>mouseout     &#x9F20;&#x6807;&#x4ECE;&#x67D0;&#x5143;&#x7D20;&#x79FB;&#x5F00;&#x3002;
```JavaScript
test.addEventListener(&quot;mouseout&quot;,function(){
  console.log(&quot;&#x9F20;&#x6807;&#x79FB;&#x5F00;mouseout&quot;);
  this.style.transform = &quot;scale(1)&quot;;
})</li>
</ul>
<pre><code>* mouseenter &#x5F53;&#x9F20;&#x6807;&#x6307;&#x9488;&#x79FB;&#x52A8;&#x5230;&#x5143;&#x7D20;&#x4E0A;&#x65F6;&#x89E6;&#x53D1;&#x3002;
```JavaScript
test.addEventListener(&quot;mouseenter&quot;,function(){
    console.log(&quot;&#x9F20;&#x6807;&#x8FDB;&#x5165;mouseenter&quot;);
    this.style.transform = &quot;scale(1.2)&quot;;
})
</code></pre><ul>
<li>mouseleave &#x5F53;&#x9F20;&#x6807;&#x6307;&#x9488;&#x79FB;&#x51FA;&#x5143;&#x7D20;&#x65F6;&#x89E6;&#x53D1;<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;mouseleave&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x9F20;&#x6807;&#x79FB;&#x5F00;mouseleave&quot;</span>);
  <span class="hljs-keyword">this</span>.style.transform = <span class="hljs-string">&quot;scale(1)&quot;</span>;
})
</code></pre>
</li>
<li><p>mousemove &#x9F20;&#x6807;&#x88AB;&#x79FB;&#x52A8;</p>
<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;mousemove&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>)</span>{
<span class="hljs-comment">//e.clientX &#x8FD4;&#x56DE;&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x65F6;&#x9F20;&#x6807;&#x8DDD;&#x79BB;&#x6D4F;&#x89C8;&#x5668;&#x5DE6;&#x4FA7;&#x7684;&#x8DDD;&#x79BB;</span>
<span class="hljs-comment">//e.clientY &#x8FD4;&#x56DE;&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x65F6;&#x9F20;&#x6807;&#x8DDD;&#x79BB;&#x6D4F;&#x89C8;&#x5668;&#x4E0A;&#x9762;&#x7684;&#x8DDD;&#x79BB;</span>
  <span class="hljs-built_in">console</span>.log(e.clientX,e.clientY);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x9F20;&#x6807;&#x79FB;&#x52A8;mousemove&quot;</span>);
  <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-number">1000</span>;i++){

  }
})
</code></pre>
</li>
</ul>
<h4 id="113-&#x53CC;&#x51FB;&#x4E8B;&#x4EF6;">11.3 &#x53CC;&#x51FB;&#x4E8B;&#x4EF6;</h4>
<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;dblclick&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x53CC;&#x51FB;&#x4E8B;&#x4EF6;&quot;</span>);
})
</code></pre>
<h4 id="114-&#x952E;&#x76D8;&#x4E8B;&#x4EF6;">11.4 &#x952E;&#x76D8;&#x4E8B;&#x4EF6;</h4>
<ul>
<li>keydown -&gt; keypress -&gt; keyup<ul>
<li>&#x4E8B;&#x4EF6;&#x5BF9;&#x8C61;,&#x987E;&#x540D;&#x601D;&#x4E49;&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;</li>
<li>&#x4E8B;&#x4EF6;&#x5BF9;&#x8C61;&#x662F;&#x5F53;&#x4E8B;&#x4EF6;&#x53D1;&#x751F;&#x65F6;&#x751F;&#x6210;</li>
<li>&#x4E8B;&#x4EF6;&#x5BF9;&#x8C61;&#x4F1A;&#x4F5C;&#x4E3A;&#x4E8B;&#x4EF6;&#x53E5;&#x67C4;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F20;&#x5165;</li>
</ul>
</li>
<li>keydown     &#x67D0;&#x4E2A;&#x952E;&#x76D8;&#x6309;&#x952E;&#x88AB;&#x6309;&#x4E0B;&#x3002;    <pre><code class="lang-JavaScript"><span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">&quot;keydown&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>)</span>{
  <span class="hljs-built_in">console</span>.log(e.keyCode);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x6309;&#x4E0B;&#x4E86;&quot;</span>);
})
</code></pre>
</li>
<li>keyup &#x67D0;&#x4E2A;&#x952E;&#x76D8;&#x6309;&#x952E;&#x88AB;&#x677E;&#x5F00; <pre><code class="lang-JavaScript"><span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">&quot;keyup&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>)</span>{
  <span class="hljs-built_in">console</span>.log(e.keyCode);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x677E;&#x5F00;&#x4E86;&quot;</span>);
})
</code></pre>
</li>
<li>keypress &#x67D0;&#x4E2A;&#x952E;&#x76D8;&#x6309;&#x952E;&#x88AB;&#x6309;&#x4E0B;&#x5E76;&#x677E;&#x5F00;&#x3002;<pre><code class="lang-JavaScript"><span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">&quot;keypress&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>)</span>{
  <span class="hljs-built_in">console</span>.log(e.keyCode); 
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;press&#x4E8B;&#x4EF6;&quot;</span>);
})
</code></pre>
<h4 id="115-&#x8868;&#x5355;&#x4E8B;&#x4EF6;&#x6D4B;&#x8BD5;">11.5 &#x8868;&#x5355;&#x4E8B;&#x4EF6;&#x6D4B;&#x8BD5;</h4>
</li>
<li>focus &#x83B7;&#x53D6;&#x7126;&#x70B9;<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> ipt = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;input&quot;</span>);
ipt.addEventListener(<span class="hljs-string">&quot;focus&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-keyword">this</span>.style.height = <span class="hljs-string">&quot;80px&quot;</span>;
})
</code></pre>
</li>
<li>blur &#x5931;&#x53BB;&#x7126;&#x70B9;<pre><code class="lang-JavaScript">ipt.addEventListener(<span class="hljs-string">&quot;blur&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-keyword">this</span>.style.height = <span class="hljs-string">&quot;30px&quot;</span>;
})
</code></pre>
</li>
<li>change &#x662F;&#x53EA;&#x6709;&#x5185;&#x5BB9;&#x66F4;&#x6539;&#x540E;&#x5931;&#x53BB;&#x7126;&#x70B9;&#x65F6;,&#x624D;&#x4F1A;&#x89E6;&#x53D1;<pre><code class="lang-JavaScript">ipt.addEventListener(<span class="hljs-string">&quot;change&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.value);
})
</code></pre>
</li>
<li>input &#x53EA;&#x8981;&#x5185;&#x5BB9;&#x6709;&#x6539;&#x53D8;&#x5C31;&#x4F1A;&#x7ACB;&#x5373;&#x89E6;&#x53D1;<pre><code class="lang-JavaScript">ipt.addEventListener(<span class="hljs-string">&quot;input&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.value);
})
</code></pre>
</li>
</ul>
<h4 id="116-&#x8FC7;&#x6E21;&#x4E8B;&#x4EF6;">11.6 &#x8FC7;&#x6E21;&#x4E8B;&#x4EF6;</h4>
<pre><code class="lang-JavaScript">test.addEventListener(<span class="hljs-string">&quot;transitionend&quot;</span>,tran)
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">tran</span>(<span class="hljs-params"></span>)</span>{
    alert(<span class="hljs-string">&quot;&#x8FC7;&#x6E21;&#x52A8;&#x753B;&#x7ED3;&#x675F;&quot;</span>);
    <span class="hljs-comment">//&#x5982;&#x4F55;&#x79FB;&#x9664;&#x4E8B;&#x4EF6;&#x76D1;&#x542C;</span>
    test.removeEventListener(<span class="hljs-string">&quot;transitionend&quot;</span>,tran);
}
</code></pre>
<h3 id="&#x7B2C;&#x5341;&#x4E8C;&#x8282;-&#x4E8B;&#x4EF6;&#x5BF9;&#x8C61;">&#x7B2C;&#x5341;&#x4E8C;&#x8282; &#x4E8B;&#x4EF6;&#x5BF9;&#x8C61;</h3>
<p>&#x4E8B;&#x4EF6;&#x5BF9;&#x8C61;</p>
<ul>
<li>1.&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;,&#x901A;&#x8FC7;&#x4ED6;&#x7684;&#x5C5E;&#x6027;&#x53EF;&#x4EE5;&#x83B7;&#x53D6;&#x6570;&#x636E;,&#x901A;&#x8FC7;&#x4ED6;&#x7684;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x4E00;&#x5B9A;&#x7684;&#x529F;&#x80FD;</li>
<li>2.&#x53EA;&#x6709;&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x65F6;&#x624D;&#x4F1A;&#x4EA7;&#x751F;</li>
<li><p>3.&#x4ED6;&#x4F5C;&#x4E3A;&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x51FD;&#x6570;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F20;&#x8FDB;&#x6765;(&#x5B9E;&#x53C2;)</p>
</li>
<li><p>addEventListener &#x7684;&#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;,&#x51B3;&#x5B9A;&#x4E86;&#x76D1;&#x542C;&#x4E8B;&#x4EF6;&#x662F;&#x5728;&#x6355;&#x83B7;&#x9636;&#x6BB5;&#x8FD8;&#x662F;&#x5728;&#x5192;&#x6CE1;&#x9636;&#x6BB5;,&#x9ED8;&#x8BA4;&#x4E3A;false,&#x5373;&#x5192;&#x6CE1;&#x9636;&#x6BB5;</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> baba = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;.baba&quot;</span>);
<span class="hljs-keyword">var</span> son = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;.son&quot;</span>);
baba.addEventListener(<span class="hljs-string">&quot;click&quot;</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;baba_target&quot;</span>, e.target);<span class="hljs-comment">//target &#x4E8B;&#x4EF6;&#x5C5E;&#x6027;&#x53EF;&#x8FD4;&#x56DE;&#x4E8B;&#x4EF6;&#x7684;&#x76EE;&#x6807;&#x8282;&#x70B9;&#xFF08;&#x89E6;&#x53D1;&#x8BE5;&#x4E8B;&#x4EF6;&#x7684;&#x8282;&#x70B9;&#xFF09;&#xFF0C;&#x5982;&#x751F;&#x6210;&#x4E8B;&#x4EF6;&#x7684;&#x5143;&#x7D20;&#x3001;&#x6587;&#x6863;&#x6216;&#x7A97;&#x53E3;&#x3002;</span>
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;baba_currentTarget&quot;</span>, e.currentTarget);<span class="hljs-comment">//currentTarget &#x4E8B;&#x4EF6;&#x5C5E;&#x6027;&#x8FD4;&#x56DE;&#x5176;&#x76D1;&#x542C;&#x5668;&#x89E6;&#x53D1;&#x4E8B;&#x4EF6;&#x7684;&#x8282;&#x70B9;&#xFF0C;&#x5373;&#x5F53;&#x524D;&#x5904;&#x7406;&#x8BE5;&#x4E8B;&#x4EF6;&#x7684;&#x5143;&#x7D20;&#x3001;&#x6587;&#x6863;&#x6216;&#x7A97;&#x53E3;&#x3002;</span>
&#x5728;&#x6355;&#x83B7;&#x548C;&#x8D77;&#x6CE1;&#x9636;&#x6BB5;&#xFF0C;&#x8BE5;&#x5C5E;&#x6027;&#x662F;&#x975E;&#x5E38;&#x6709;&#x7528;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x5728;&#x8FD9;&#x4E24;&#x4E2A;&#x8282;&#x70B9;&#xFF0C;&#x5B83;&#x4E0D;&#x540C;&#x4E8E; target &#x5C5E;&#x6027;
  alert(<span class="hljs-string">&quot;&#x6211;&#x662F;&#x7238;&#x7238;&quot;</span>);
}, <span class="hljs-literal">true</span>) <span class="hljs-comment">//addEventListener &#x7684;&#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;,&#x51B3;&#x5B9A;&#x4E86;&#x76D1;&#x542C;&#x4E8B;&#x4EF6;&#x662F;&#x5728;&#x6355;&#x83B7;&#x9636;&#x6BB5;&#x8FD8;&#x662F;&#x5728;&#x5192;&#x6CE1;&#x9636;&#x6BB5;,&#x9ED8;&#x8BA4;&#x4E3A;false,&#x5373;&#x5192;&#x6CE1;&#x9636;&#x6BB5;</span>
</code></pre>
</li>
<li><p>stopPropagation(); &#x963B;&#x6B62;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;</p>
<pre><code class="lang-JavaScript">son.addEventListener(<span class="hljs-string">&quot;click&quot;</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>) </span>{
  <span class="hljs-comment">//e.stopPropagation(e);//&#x963B;&#x6B62;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;</span>
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;son_target&quot;</span>, e.target);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;son_currentTarget&quot;</span>, e.currentTarget);
  alert(<span class="hljs-string">&quot;&#x6211;&#x662F;&#x513F;&#x5B50;&quot;</span>);
}, <span class="hljs-literal">true</span>)
</code></pre>
</li>
<li><p>preventDefault(); &#x963B;&#x6B62;&#x9ED8;&#x8BA4;&#x4E8B;&#x4EF6;</p>
<pre><code class="lang-JavaScript"><span class="hljs-keyword">var</span> aLink = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;a&quot;</span>);
aLink.addEventListener(<span class="hljs-string">&quot;click&quot;</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">evt</span>) </span>{
  evt.preventDefault(); <span class="hljs-comment">//&#x963B;&#x6B62;&#x9ED8;&#x8BA4;&#x4E8B;&#x4EF6;</span>
})
</code></pre>
</li>
</ul>
<h3 id="&#x7B2C;&#x5341;&#x4E09;&#x8282;-&#x79FB;&#x52A8;&#x7AEF;&#x4E8B;&#x4EF6;">&#x7B2C;&#x5341;&#x4E09;&#x8282; &#x79FB;&#x52A8;&#x7AEF;&#x4E8B;&#x4EF6;</h3>
<p>&#x79FB;&#x52A8;&#x7AEF;&#x4E8B;&#x4EF6;</p>
<ul>
<li><p>touchstart: &#x624B;&#x6307;&#x6309;&#x4E0B;&#x5C4F;&#x5E55;&#x65F6;&#x89E6;&#x53D1;
```JavaScript
var div = document.querySelector(&quot;.test&quot;);
var oriDis;
div.addEventListener(&quot;touchstart&quot;,function(e){
  console.log(&quot;touchstart&#x89E6;&#x53D1;&quot;);
//                console.log(e);
//                console.log(e.touches[0].clientX);
  //e.touches &#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;,&#x6570;&#x7EC4;&#x5143;&#x7D20;&#x5206;&#x522B;&#x5B58;&#x50A8;&#x4E86;&#x89E6;&#x6478;&#x70B9;&#x7684;&#x4FE1;&#x606F;
  if(e.touches.length&gt;1){</p>
<pre><code>  var firstX = e.touches[0].clientX;
  var firstY = e.touches[0].clientY;
  var secX = e.touches[1].clientX;
  var secY = e.touches[1].clientY;
  oriDis = Math.sqrt(Math.pow((firstX-secX),2)+(firstY-secY)*(firstY-secY));
</code></pre><p>//                    console.log(dis);</p>
<p>  }</p>
</li>
</ul>
<p>})</p>
<pre><code>* touchend: &#x624B;&#x6307;&#x6309;&#x4E0B;&#x540E;&#x79BB;&#x5F00;&#x65F6;&#x89E6;&#x53D1;
```JavaScript
div.addEventListener(&quot;touchend&quot;,function(e){
    console.log(&quot;touchend&#x89E6;&#x53D1;&quot;);
//                console.log(e);
})
</code></pre><ul>
<li>touchmove: &#x624B;&#x6307;&#x5728;&#x5C4F;&#x5E55;&#x4E0A;&#x79FB;&#x52A8;&#x65F6;&#x89E6;&#x53D1;
```JavaScript
div.addEventListener(&quot;touchmove&quot;,function(e){
console.log(&quot;touchmove&#x89E6;&#x53D1;&quot;);
//                console.log(e);
if(e.touches.length&gt;1){
  var firstX = e.touches[0].clientX;
  var firstY = e.touches[0].clientY;
  var secX = e.touches[1].clientX;
  var secY = e.touches[1].clientY;
  var dis = Math.sqrt(Math.pow((firstX-secX),2)+(firstY-secY)*(firstY-secY));
  console.log(dis-oriDis);</li>
</ul>
<p>}
})</p>
<pre><code>* touchcancel: &#x89E6;&#x6478;&#x4E8B;&#x4EF6;&#x53D6;&#x6D88;&#x65F6;&#x89E6;&#x53D1;

###&#x7B2C;&#x5341;&#x56DB;&#x8282; touch &#x4E8B;&#x4EF6;
* touch.on() &#x6DFB;&#x52A0;&#x76D1;&#x542C;&#x4E8B;&#x4EF6;
* &#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x4E00;&#x4E2A;CSS3&#x9009;&#x62E9;&#x5668;,&#x8868;&#x793A;&#x76EE;&#x6807;&#x5BF9;&#x8C61;
* &#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x8981;&#x76D1;&#x542C;&#x7684;&#x4E8B;&#x4EF6;&#x540D;
* &#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x65F6;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;
```JavaScript
var test = document.querySelectorAll(&quot;.test&quot;);
test.forEach(function(v){
    v.lastRota = 0;
    v.finalRota = 0;
})
touch.on(&quot;.test&quot;,&quot;rotate&quot;,function(e){
//    console.log(e);
    this.finalRota = this.lastRota + e.rotation;
    this.style.transform = &quot;rotate(&quot;+this.finalRota +&quot;deg)&quot;;
    if(e.fingerStatus == &quot;end&quot;){
        this.lastRota = this.finalRota;
    }
})
</code></pre><ul>
<li>swipe &#x5FEB;&#x901F;&#x79FB;&#x52A8;&#x89E6;&#x53D1;<pre><code class="lang-JavaScript">touch.on(<span class="hljs-string">&quot;.test&quot;</span>,<span class="hljs-string">&quot;swipe&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>)</span>{
  <span class="hljs-built_in">console</span>.log(e);
})
</code></pre>
</li>
<li>drag &#x62D6;&#x52A8;<pre><code class="lang-JavaScript">touch.on(<span class="hljs-string">&quot;.test&quot;</span>,<span class="hljs-string">&quot;drag&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>)</span>{
  <span class="hljs-built_in">console</span>.log(e);
})
</code></pre>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../md/js/js数组对象.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 数组对象"><i class="fa fa-angle-left"></i></a>
        
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"expandable-chapters-interactive":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
